<?php


$MTPSReleaseTime = 1570418130; setlocale(LC_ALL,'cs_CZ');
date_default_timezone_set("Europe/Prague");
function WriteLog($str) { $path = str_replace("//","/",$_SERVER['DOCUMENT_ROOT']."/")."logs/"; @mkdir($path); file_put_contents($path."log-".Date("Y-m-d").".txt",Date("[Y-m-d H:i:s] ").$_SERVER['REQUEST_URI'].": ".$str."\n",FILE_APPEND); }
function utf8_substr($str,$from,$len=-1) {
    if($len == -1) { $len = strlen($str); }
    return mb_substr($str,$from,$len,'UTF-8');}
function IsLanguage($str) {
    if(strlen($str) != 2) { return false; }
    switch($str) {
        case "cs": case "sk": case "en": case "de": case "fr": case "sr": case "ru": case "es": case "it":
        return true;}
    return false;}
function IsNownWebSection($section) {
    switch($section) {
        case "MTPSCreateTables":
        case "js":
        case "css":
        case "api":
        case "app":
        case "pim":
        case "ajax":
        case "admin":
        case "forms":
        case "cron":
        case "user":
        case "uzivatel":
        case "intranet":
        case "news":
        case "aktuality":
        case "image":
            return true;}
    return false;}

function UrlPathToArray($url_path,&$count,&$language="") {
    global $MTPS;
    $count = 0; $language = ""; $arr1 = array(); $arr2 = explode('/',$url_path);
    foreach($arr2 as $key => $val) {
        if($val != "") {
            if($count == 0 && IsLanguage($val)) {
                $language = $val;
                $MTPS->Language = $val;
                $MTPS->ForcedLanguage = $val;}
            else {
                if($count == 0 && $MTPS->DefaultURL != "" && IsNownWebSection($MTPS->DefaultURL) && !IsNownWebSection($val)) {
                    $arr1[$count] = $MTPS->DefaultURL;
                    $count++;}
                $arr1[$count] = $val;
                $count++;}}}
    if($count == 0 && $MTPS->DefaultURL != "" && IsNownWebSection($MTPS->DefaultURL)) {
        $arr1[$count] = $MTPS->DefaultURL; $count++;}
    return $arr1;}
function GetToArray($get) {
    foreach(explode('&',$get) as $key => $val) {
        if($val != "") { if(($pos = strpos($val,"=",0)) !== false) { $get_key = utf8_substr($val,0,$pos); $get_val = utf8_substr($val,$pos+1); $_GET[$get_key] = $get_val; } }}}
error_reporting(E_ALL ^ E_DEPRECATED);
@session_start();
if(IsSet($argv) && IsSet($argv[1]) && IsSet($argv[2])) {
/*    if($argv[1] == "WSServer" && $argv[2] != "") {
        switch($argv[2]) {
            case "dev-zm":
                $_GET['WSServer'] = $argv[2];
                $_SERVER['HTTP_HOST'] = "dev-zm.mestokralupy.cz";
                $_SERVER['DOCUMENT_ROOT'] = "C:/Webs/zm/www/";
                $_SERVER['REQUEST_URI'] = "/";
                break;
            case "172.16.2.250":
                $_GET['WSServer'] = $argv[2];
                $_SERVER['HTTP_HOST'] = "172.16.2.250";
                $_SERVER['DOCUMENT_ROOT'] = "C:/Webs/zm/www/";
                $_SERVER['REQUEST_URI'] = "/";
                break;
            case "kpy-zm":
                $_GET['WSServer'] = $argv[2];
                $_SERVER['HTTP_HOST'] = "zm.mestokralupy.cz";
                $_SERVER['DOCUMENT_ROOT'] = "/var/www/zm/www/";
                $_SERVER['REQUEST_URI'] = "/";
                break;
            default:
                $_GET['WSServer'] = $argv[2];
                $_SERVER['HTTP_HOST'] = "www.casospravce.mukpy.cz";
                $_SERVER['DOCUMENT_ROOT'] = "C:/Webs/spravcecasu/www/";
                $_SERVER['REQUEST_URI'] = "/";
                break;}
    }*/
}
if(IsSet($_SERVER['REQUEST_URI'])) {
    if($_SERVER['REQUEST_URI'] == "/favicon.ico") { Header('Content-Type: text/html; charset=utf-8','',404); exit(); }
    if($_SERVER['REQUEST_URI'] == "/apple-touch-icon.png") { Header('Content-Type: text/html; charset=utf-8','',404); exit(); }
    if($_SERVER['REQUEST_URI'] == "/apple-touch-icon-precomposed.png") { Header('Content-Type: text/html; charset=utf-8','',404); exit(); }}
if(!IsSet($MTPSReleaseTime)) { $MTPSReleaseTime = Time(); }
$Colors = array();
if(!defined("mtps3")) { $___IS_MTPS2 = true; }
class MTPS {
    public $SupportedLanguages = array("cs");
    //public $SupportedLanguages = array("cs","en");

    public $Language = "cs";
    public $ForcedLanguage = "cs";
    public $Charset = "utf-8";
    public $PHP = 0;
    public $Host = "";
    public $HTTPS = 0;
    public $Page = false;
    public $PageID = 0;
    public $IsIndexPage = false;
    public $PageParents = array();
    public $PageParentsCount = 0;
    public $WebTree = null;
    public $WebTreeTime = 0;
    public $WebTreeLastUpdate = 0;
    public $WebURLs = null;
    public $WebURLsCount = 0;
    public $Settings = array();
    public $MainFile = "index.php";
    public $DefaultLayout = "default";
    public $SubLayout = array();
    public $DefaultURL = "";
    public $PreviousURL = "";
    public $SectionFound = false;
    public $PublishingSystemName = "Monotea Publishing System 2.17";
    public $PublishingSystemURL = "http://www.monotea.com/?referer=MTPS2";
    public $Title = "";
    public $OnlyAdminCanCreateNewAccount = true;
    public $UsernameIsEmail = false;
    public $jsLoginScreen = false;
    public $LoginByID = false;
    public $LoginByUsername = false;
    public $LoginByEmail = false;
    public $LoginShowButton_Registration = 0;
    public $LoginShowButton_LanguageSelect = false;
    public $LoginShowButton_Newbie = 0;
    public $LoginShowButton_NewbieTitle = 0;
    public $SaveWebAccess = false;
    public $WebAccessID = 0;
    public $SaveDBRequests = false;
    public $Date;
    public $IP = "0.0.0.0";
    public $HttpProtocol = 0;
    public $HttpResponseCode = 200;
    public $DefaultLanguageInLink = false;
    public $Device;
    public $ClientLayout = 0;
    public $RealClientLayout = 0;
    public $SaveStats = false;
    public $URL;
    public $GetString = "";
    public $Path = "";
    public $PathString = "";
    public $PathCount = 0;
    public $PathOne = "";
    public $PathTwo = "";
    public $PathThree = "";
    public $PathFour = "";
    public $PathFive = "";
    public $CharsetHeaderWritten = false;
    public $UserCanBuyLicense = false;
    public $WebLanguages = array();
    public $WebLanguagesCount = 0;
    public $PageTypes = array();
    public $PageTypesCount = 0;
    public $AlbumVisibility = array();
    public $AlbumVisibilityCount = 0;
    public $DefaultUserAccountPassword = "";
    public $Sessions = array();
    public $SessionsCount = 0;
    public $SecondaryHttpHost = "___domain.tld";
    public $NewsIconWidth = 12;
    public $FullNewsIconWidth = 16;
    public $FullCalendarItemIconWidth = 16;
    public $InstitutionIconWidth = 12;
    public $SubpagesEditable = true;
    public $NewsIconPixelMaxDimension = 800;
    public $ShowingPIMBox = false;
    public $MakeImagesClickable = true;
    public $WriteNothing = false;
    public $UsersRights = null;
    public $UsersRightsCount = 0;
    public $kwiModules = array();};
$MTPS = new MTPS;
echo "ahoj";
$MTPS->Date = Date("Y-m-d");
$MTPS->Settings['EnableGallery'] = true;
$MTPS->Settings['DataRefreshInterval'] = 900;
$MTPS->Settings['SecondaryDataRefreshInterval'] = 900;
if(IsSet($_GET['MTPS2GET'])) {
    UnSet($_GET['MTPS2GET']);}
if(IsSet($_SERVER['REQUEST_URI'])) {
    $len = strlen($_SERVER['REQUEST_URI']);
    if(($pos = strpos($_SERVER['REQUEST_URI'],"?",0)) !== false) {
        $MTPS->GetString = utf8_substr($_SERVER['REQUEST_URI'],$pos+1);
        GetToArray($MTPS->GetString);
        $len = $pos;}}
if(IsSet($_GET['ApiCall']) && $_GET['ApiCall'] == 1) { $ApiCall = true; } else { $ApiCall = false; }
$phpversion = explode(".",phpversion());
$MTPS->PHP = $phpversion[0].".".$phpversion[1];

if((IsSet($_SERVER['HTTPS']) && $_SERVER["HTTPS"] == "on") || (IsSet($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443)
   || (IsSet($_SERVER['HTTP_HTTPS']) && ($_SERVER['HTTP_HTTPS'] == "1, on" || $_SERVER['HTTP_HTTPS'] == "on")))
{
    $MTPS->HTTPS = 1;
    $MTPS->HttpProtocol = 1;
    $MTPS->URL = "https://";
/*    WriteLog('HTTP_HTTPS je 1 ,'.$_SERVER['HTTP_HTTPS'] .",".$_SERVER['HTTPS']);*/
    WriteLog("HTTP_HTTPS je  ".$_SERVER['HTTPS']);
    }
else {
    //WriteLog('HTTP_HTTPS je 0 ,'.$_SERVER['HTTP_HTTPS'] .",".$_SERVER['HTTPS']);

    $MTPS->HTTPS = 0;
    $MTPS->URL = "https://";
    }
class MODULE {
    public $Enabled = false;};
$MODULES['pim'] = new MODULE;
$MODULES['cityhall'] = new MODULE;
$urlWEB = $MTPS->URL.@str_replace("//","/",$_SERVER['HTTP_HOST']."/");
$urlWEBSSL = "https://".@str_replace("//","/",$_SERVER['HTTP_HOST']."/");
$urlWEB_NO_LNG = $urlWEB;
$fileWEB = str_replace("//","/",$_SERVER['DOCUMENT_ROOT']."/");
$fileFILES = $fileWEB."files/";
$fileFILES = str_replace("/mtps2/","/",$fileFILES);
$imgWEB = $urlWEB;
$urlTEMPLATES = $urlWEB."templates/";
$fileTEMPLATES = $fileWEB."templates/";
$file = __FILE__;
if(strpos($file,"/mtps2") !== false || strpos($file,"\\mtps2") !== false) {
    $urlMTPS = $urlWEB."mtps2/";
    $fileMTPS = $fileWEB."mtps2/";
    $urlMTPSSSL = $urlWEBSSL."mtps2/";}
else {
    $urlMTPS = $urlWEB;
    $fileMTPS = $fileWEB;
    $urlMTPSSSL = $urlWEBSSL;}
$urlIMG = $urlMTPS."img/";
$fileIMG = $fileMTPS."img/";
$urlLOADER = $urlIMG."loader/";
$urlBLOG = $urlWEB; $urlBLOG_Prefix = "";
$urlESHOP = $urlWEB; $urlESHOP_Prefix = "";
if(@file_exists("mpdf-7.0/mpdf.php")) {
    include("mpdf-7.0/mpdf.php");}
class Mobile_Detect
{
    const DETECTION_TYPE_MOBILE = 'mobile';
    const DETECTION_TYPE_EXTENDED = 'extended';
    const VER = '([\w._\+]+)';
    const MOBILE_GRADE_A = 'A';
    const MOBILE_GRADE_B = 'B';
    const MOBILE_GRADE_C = 'C';
    const VERSION = '2.8.24';
    const VERSION_TYPE_STRING = 'text';
    const VERSION_TYPE_FLOAT = 'float';
    protected $cache = array();
    protected $userAgent = null;
    protected $httpHeaders = array();
    protected $cloudfrontHeaders = array();
    protected $matchingRegex = null;
    protected $matchesArray = null;
    protected $detectionType = self::DETECTION_TYPE_MOBILE;
    protected static $mobileHeaders = array(
        'HTTP_ACCEPT' => array('matches' => array(
            'application/x-obml2d',
            'application/vnd.rim.html',
            'text/vnd.wap.wml',
            'application/vnd.wap.xhtml+xml'
        )),
        'HTTP_X_WAP_PROFILE' => null,
        'HTTP_X_WAP_CLIENTID' => null,
        'HTTP_WAP_CONNECTION' => null,
        'HTTP_PROFILE' => null,
        'HTTP_X_OPERAMINI_PHONE_UA' => null,
        'HTTP_X_NOKIA_GATEWAY_ID' => null,
        'HTTP_X_ORANGE_ID' => null,
        'HTTP_X_VODAFONE_3GPDPCONTEXT' => null,
        'HTTP_X_HUAWEI_USERID' => null,
        'HTTP_UA_OS' => null,
        'HTTP_X_MOBILE_GATEWAY' => null,
        'HTTP_X_ATT_DEVICEID' => null,
        'HTTP_UA_CPU' => array('matches' => array('ARM')),);
    protected static $phoneDevices = array(
        'iPhone' => '\biPhone\b|\biPod\b',
        'BlackBerry' => 'BlackBerry|\bBB10\b|rim[0-9]+',
        'HTC' => 'HTC|HTC.*(Sensation|Evo|Vision|Explorer|6800|8100|8900|A7272|S510e|C110e|Legend|Desire|T8282)|APX515CKT|Qtek9090|APA9292KT|HD_mini|Sensation.*Z710e|PG86100|Z715e|Desire.*(A8181|HD)|ADR6200|ADR6400L|ADR6425|001HT|Inspire 4G|Android.*\bEVO\b|T-Mobile G1|Z520m',
        'Nexus' => 'Nexus One|Nexus S|Galaxy.*Nexus|Android.*Nexus.*Mobile|Nexus 4|Nexus 5|Nexus 6',
        'Dell' => 'Dell.*Streak|Dell.*Aero|Dell.*Venue|DELL.*Venue Pro|Dell Flash|Dell Smoke|Dell Mini 3iX|XCD28|XCD35|\b001DL\b|\b101DL\b|\bGS01\b',
        'Motorola' => 'Motorola|DROIDX|DROID BIONIC|\bDroid\b.*Build|Android.*Xoom|HRI39|MOT-|A1260|A1680|A555|A853|A855|A953|A955|A956|Motorola.*ELECTRIFY|Motorola.*i1|i867|i940|MB200|MB300|MB501|MB502|MB508|MB511|MB520|MB525|MB526|MB611|MB612|MB632|MB810|MB855|MB860|MB861|MB865|MB870|ME501|ME502|ME511|ME525|ME600|ME632|ME722|ME811|ME860|ME863|ME865|MT620|MT710|MT716|MT720|MT810|MT870|MT917|Motorola.*TITANIUM|WX435|WX445|XT300|XT301|XT311|XT316|XT317|XT319|XT320|XT390|XT502|XT530|XT531|XT532|XT535|XT603|XT610|XT611|XT615|XT681|XT701|XT702|XT711|XT720|XT800|XT806|XT860|XT862|XT875|XT882|XT883|XT894|XT901|XT907|XT909|XT910|XT912|XT928|XT926|XT915|XT919|XT925|XT1021|\bMoto E\b',
        'Samsung' => '\bSamsung\b|SM-G9250|GT-19300|SGH-I337|BGT-S5230|GT-B2100|GT-B2700|GT-B2710|GT-B3210|GT-B3310|GT-B3410|GT-B3730|GT-B3740|GT-B5510|GT-B5512|GT-B5722|GT-B6520|GT-B7300|GT-B7320|GT-B7330|GT-B7350|GT-B7510|GT-B7722|GT-B7800|GT-C3010|GT-C3011|GT-C3060|GT-C3200|GT-C3212|GT-C3212I|GT-C3262|GT-C3222|GT-C3300|GT-C3300K|GT-C3303|GT-C3303K|GT-C3310|GT-C3322|GT-C3330|GT-C3350|GT-C3500|GT-C3510|GT-C3530|GT-C3630|GT-C3780|GT-C5010|GT-C5212|GT-C6620|GT-C6625|GT-C6712|GT-E1050|GT-E1070|GT-E1075|GT-E1080|GT-E1081|GT-E1085|GT-E1087|GT-E1100|GT-E1107|GT-E1110|GT-E1120|GT-E1125|GT-E1130|GT-E1160|GT-E1170|GT-E1175|GT-E1180|GT-E1182|GT-E1200|GT-E1210|GT-E1225|GT-E1230|GT-E1390|GT-E2100|GT-E2120|GT-E2121|GT-E2152|GT-E2220|GT-E2222|GT-E2230|GT-E2232|GT-E2250|GT-E2370|GT-E2550|GT-E2652|GT-E3210|GT-E3213|GT-I5500|GT-I5503|GT-I5700|GT-I5800|GT-I5801|GT-I6410|GT-I6420|GT-I7110|GT-I7410|GT-I7500|GT-I8000|GT-I8150|GT-I8160|GT-I8190|GT-I8320|GT-I8330|GT-I8350|GT-I8530|GT-I8700|GT-I8703|GT-I8910|GT-I9000|GT-I9001|GT-I9003|GT-I9010|GT-I9020|GT-I9023|GT-I9070|GT-I9082|GT-I9100|GT-I9103|GT-I9220|GT-I9250|GT-I9300|GT-I9305|GT-I9500|GT-I9505|GT-M3510|GT-M5650|GT-M7500|GT-M7600|GT-M7603|GT-M8800|GT-M8910|GT-N7000|GT-S3110|GT-S3310|GT-S3350|GT-S3353|GT-S3370|GT-S3650|GT-S3653|GT-S3770|GT-S3850|GT-S5210|GT-S5220|GT-S5229|GT-S5230|GT-S5233|GT-S5250|GT-S5253|GT-S5260|GT-S5263|GT-S5270|GT-S5300|GT-S5330|GT-S5350|GT-S5360|GT-S5363|GT-S5369|GT-S5380|GT-S5380D|GT-S5560|GT-S5570|GT-S5600|GT-S5603|GT-S5610|GT-S5620|GT-S5660|GT-S5670|GT-S5690|GT-S5750|GT-S5780|GT-S5830|GT-S5839|GT-S6102|GT-S6500|GT-S7070|GT-S7200|GT-S7220|GT-S7230|GT-S7233|GT-S7250|GT-S7500|GT-S7530|GT-S7550|GT-S7562|GT-S7710|GT-S8000|GT-S8003|GT-S8500|GT-S8530|GT-S8600|SCH-A310|SCH-A530|SCH-A570|SCH-A610|SCH-A630|SCH-A650|SCH-A790|SCH-A795|SCH-A850|SCH-A870|SCH-A890|SCH-A930|SCH-A950|SCH-A970|SCH-A990|SCH-I100|SCH-I110|SCH-I400|SCH-I405|SCH-I500|SCH-I510|SCH-I515|SCH-I600|SCH-I730|SCH-I760|SCH-I770|SCH-I830|SCH-I910|SCH-I920|SCH-I959|SCH-LC11|SCH-N150|SCH-N300|SCH-R100|SCH-R300|SCH-R351|SCH-R400|SCH-R410|SCH-T300|SCH-U310|SCH-U320|SCH-U350|SCH-U360|SCH-U365|SCH-U370|SCH-U380|SCH-U410|SCH-U430|SCH-U450|SCH-U460|SCH-U470|SCH-U490|SCH-U540|SCH-U550|SCH-U620|SCH-U640|SCH-U650|SCH-U660|SCH-U700|SCH-U740|SCH-U750|SCH-U810|SCH-U820|SCH-U900|SCH-U940|SCH-U960|SCS-26UC|SGH-A107|SGH-A117|SGH-A127|SGH-A137|SGH-A157|SGH-A167|SGH-A177|SGH-A187|SGH-A197|SGH-A227|SGH-A237|SGH-A257|SGH-A437|SGH-A517|SGH-A597|SGH-A637|SGH-A657|SGH-A667|SGH-A687|SGH-A697|SGH-A707|SGH-A717|SGH-A727|SGH-A737|SGH-A747|SGH-A767|SGH-A777|SGH-A797|SGH-A817|SGH-A827|SGH-A837|SGH-A847|SGH-A867|SGH-A877|SGH-A887|SGH-A897|SGH-A927|SGH-B100|SGH-B130|SGH-B200|SGH-B220|SGH-C100|SGH-C110|SGH-C120|SGH-C130|SGH-C140|SGH-C160|SGH-C170|SGH-C180|SGH-C200|SGH-C207|SGH-C210|SGH-C225|SGH-C230|SGH-C417|SGH-C450|SGH-D307|SGH-D347|SGH-D357|SGH-D407|SGH-D415|SGH-D780|SGH-D807|SGH-D980|SGH-E105|SGH-E200|SGH-E315|SGH-E316|SGH-E317|SGH-E335|SGH-E590|SGH-E635|SGH-E715|SGH-E890|SGH-F300|SGH-F480|SGH-I200|SGH-I300|SGH-I320|SGH-I550|SGH-I577|SGH-I600|SGH-I607|SGH-I617|SGH-I627|SGH-I637|SGH-I677|SGH-I700|SGH-I717|SGH-I727|SGH-i747M|SGH-I777|SGH-I780|SGH-I827|SGH-I847|SGH-I857|SGH-I896|SGH-I897|SGH-I900|SGH-I907|SGH-I917|SGH-I927|SGH-I937|SGH-I997|SGH-J150|SGH-J200|SGH-L170|SGH-L700|SGH-M110|SGH-M150|SGH-M200|SGH-N105|SGH-N500|SGH-N600|SGH-N620|SGH-N625|SGH-N700|SGH-N710|SGH-P107|SGH-P207|SGH-P300|SGH-P310|SGH-P520|SGH-P735|SGH-P777|SGH-Q105|SGH-R210|SGH-R220|SGH-R225|SGH-S105|SGH-S307|SGH-T109|SGH-T119|SGH-T139|SGH-T209|SGH-T219|SGH-T229|SGH-T239|SGH-T249|SGH-T259|SGH-T309|SGH-T319|SGH-T329|SGH-T339|SGH-T349|SGH-T359|SGH-T369|SGH-T379|SGH-T409|SGH-T429|SGH-T439|SGH-T459|SGH-T469|SGH-T479|SGH-T499|SGH-T509|SGH-T519|SGH-T539|SGH-T559|SGH-T589|SGH-T609|SGH-T619|SGH-T629|SGH-T639|SGH-T659|SGH-T669|SGH-T679|SGH-T709|SGH-T719|SGH-T729|SGH-T739|SGH-T746|SGH-T749|SGH-T759|SGH-T769|SGH-T809|SGH-T819|SGH-T839|SGH-T919|SGH-T929|SGH-T939|SGH-T959|SGH-T989|SGH-U100|SGH-U200|SGH-U800|SGH-V205|SGH-V206|SGH-X100|SGH-X105|SGH-X120|SGH-X140|SGH-X426|SGH-X427|SGH-X475|SGH-X495|SGH-X497|SGH-X507|SGH-X600|SGH-X610|SGH-X620|SGH-X630|SGH-X700|SGH-X820|SGH-X890|SGH-Z130|SGH-Z150|SGH-Z170|SGH-ZX10|SGH-ZX20|SHW-M110|SPH-A120|SPH-A400|SPH-A420|SPH-A460|SPH-A500|SPH-A560|SPH-A600|SPH-A620|SPH-A660|SPH-A700|SPH-A740|SPH-A760|SPH-A790|SPH-A800|SPH-A820|SPH-A840|SPH-A880|SPH-A900|SPH-A940|SPH-A960|SPH-D600|SPH-D700|SPH-D710|SPH-D720|SPH-I300|SPH-I325|SPH-I330|SPH-I350|SPH-I500|SPH-I600|SPH-I700|SPH-L700|SPH-M100|SPH-M220|SPH-M240|SPH-M300|SPH-M305|SPH-M320|SPH-M330|SPH-M350|SPH-M360|SPH-M370|SPH-M380|SPH-M510|SPH-M540|SPH-M550|SPH-M560|SPH-M570|SPH-M580|SPH-M610|SPH-M620|SPH-M630|SPH-M800|SPH-M810|SPH-M850|SPH-M900|SPH-M910|SPH-M920|SPH-M930|SPH-N100|SPH-N200|SPH-N240|SPH-N300|SPH-N400|SPH-Z400|SWC-E100|SCH-i909|GT-N7100|GT-N7105|SCH-I535|SM-N900A|SGH-I317|SGH-T999L|GT-S5360B|GT-I8262|GT-S6802|GT-S6312|GT-S6310|GT-S5312|GT-S5310|GT-I9105|GT-I8510|GT-S6790N|SM-G7105|SM-N9005|GT-S5301|GT-I9295|GT-I9195|SM-C101|GT-S7392|GT-S7560|GT-B7610|GT-I5510|GT-S7582|GT-S7530E|GT-I8750|SM-G9006V|SM-G9008V|SM-G9009D|SM-G900A|SM-G900D|SM-G900F|SM-G900H|SM-G900I|SM-G900J|SM-G900K|SM-G900L|SM-G900M|SM-G900P|SM-G900R4|SM-G900S|SM-G900T|SM-G900V|SM-G900W8|SHV-E160K|SCH-P709|SCH-P729|SM-T2558|GT-I9205|SM-G9350|SM-J120F',
        'LG' => '\bLG\b;|LG[- ]?(C800|C900|E400|E610|E900|E-900|F160|F180K|F180L|F180S|730|855|L160|LS740|LS840|LS970|LU6200|MS690|MS695|MS770|MS840|MS870|MS910|P500|P700|P705|VM696|AS680|AS695|AX840|C729|E970|GS505|272|C395|E739BK|E960|L55C|L75C|LS696|LS860|P769BK|P350|P500|P509|P870|UN272|US730|VS840|VS950|LN272|LN510|LS670|LS855|LW690|MN270|MN510|P509|P769|P930|UN200|UN270|UN510|UN610|US670|US740|US760|UX265|UX840|VN271|VN530|VS660|VS700|VS740|VS750|VS910|VS920|VS930|VX9200|VX11000|AX840A|LW770|P506|P925|P999|E612|D955|D802|MS323)',
        'Sony' => 'SonyST|SonyLT|SonyEricsson|SonyEricssonLT15iv|LT18i|E10i|LT28h|LT26w|SonyEricssonMT27i|C5303|C6902|C6903|C6906|C6943|D2533',
        'Asus' => 'Asus.*Galaxy|PadFone.*Mobile',
        'NokiaLumia' => 'Lumia [0-9]{3,4}',
        'Micromax' => 'Micromax.*\b(A210|A92|A88|A72|A111|A110Q|A115|A116|A110|A90S|A26|A51|A35|A54|A25|A27|A89|A68|A65|A57|A90)\b',
        'Palm' => 'PalmSource|Palm',
        'Vertu' => 'Vertu|Vertu.*Ltd|Vertu.*Ascent|Vertu.*Ayxta|Vertu.*Constellation(F|Quest)?|Vertu.*Monika|Vertu.*Signature',
        'Pantech' => 'PANTECH|IM-A850S|IM-A840S|IM-A830L|IM-A830K|IM-A830S|IM-A820L|IM-A810K|IM-A810S|IM-A800S|IM-T100K|IM-A725L|IM-A780L|IM-A775C|IM-A770K|IM-A760S|IM-A750K|IM-A740S|IM-A730S|IM-A720L|IM-A710K|IM-A690L|IM-A690S|IM-A650S|IM-A630K|IM-A600S|VEGA PTL21|PT003|P8010|ADR910L|P6030|P6020|P9070|P4100|P9060|P5000|CDM8992|TXT8045|ADR8995|IS11PT|P2030|P6010|P8000|PT002|IS06|CDM8999|P9050|PT001|TXT8040|P2020|P9020|P2000|P7040|P7000|C790',
        'Fly' => 'IQ230|IQ444|IQ450|IQ440|IQ442|IQ441|IQ245|IQ256|IQ236|IQ255|IQ235|IQ245|IQ275|IQ240|IQ285|IQ280|IQ270|IQ260|IQ250',
        'Wiko' => 'KITE 4G|HIGHWAY|GETAWAY|STAIRWAY|DARKSIDE|DARKFULL|DARKNIGHT|DARKMOON|SLIDE|WAX 4G|RAINBOW|BLOOM|SUNSET|GOA(?!nna)|LENNY|BARRY|IGGY|OZZY|CINK FIVE|CINK PEAX|CINK PEAX 2|CINK SLIM|CINK SLIM 2|CINK +|CINK KING|CINK PEAX|CINK SLIM|SUBLIM',
        'iMobile' => 'i-mobile (IQ|i-STYLE|idea|ZAA|Hitz)',
        'SimValley' => '\b(SP-80|XT-930|SX-340|XT-930|SX-310|SP-360|SP60|SPT-800|SP-120|SPT-800|SP-140|SPX-5|SPX-8|SP-100|SPX-8|SPX-12)\b',
        'Wolfgang' => 'AT-B24D|AT-AS50HD|AT-AS40W|AT-AS55HD|AT-AS45q2|AT-B26D|AT-AS50Q',
        'Alcatel' => 'Alcatel',
        'Nintendo' => 'Nintendo 3DS',
        'Amoi' => 'Amoi',
        'INQ' => 'INQ',
        'GenericPhone' => 'Tapatalk|PDA;|SAGEM|\bmmp\b|pocket|\bpsp\b|symbian|Smartphone|smartfon|treo|up.browser|up.link|vodafone|\bwap\b|nokia|Series40|Series60|S60|SonyEricsson|N900|MAUI.*WAP.*Browser',);
    protected static $tabletDevices = array(
        'iPad' => 'iPad|iPad.*Mobile',
        'NexusTablet' => 'Android.*Nexus[\s]+(7|9|10)',
        'SamsungTablet' => 'SAMSUNG.*Tablet|Galaxy.*Tab|SC-01C|GT-P1000|GT-P1003|GT-P1010|GT-P3105|GT-P6210|GT-P6800|GT-P6810|GT-P7100|GT-P7300|GT-P7310|GT-P7500|GT-P7510|SCH-I800|SCH-I815|SCH-I905|SGH-I957|SGH-I987|SGH-T849|SGH-T859|SGH-T869|SPH-P100|GT-P3100|GT-P3108|GT-P3110|GT-P5100|GT-P5110|GT-P6200|GT-P7320|GT-P7511|GT-N8000|GT-P8510|SGH-I497|SPH-P500|SGH-T779|SCH-I705|SCH-I915|GT-N8013|GT-P3113|GT-P5113|GT-P8110|GT-N8010|GT-N8005|GT-N8020|GT-P1013|GT-P6201|GT-P7501|GT-N5100|GT-N5105|GT-N5110|SHV-E140K|SHV-E140L|SHV-E140S|SHV-E150S|SHV-E230K|SHV-E230L|SHV-E230S|SHW-M180K|SHW-M180L|SHW-M180S|SHW-M180W|SHW-M300W|SHW-M305W|SHW-M380K|SHW-M380S|SHW-M380W|SHW-M430W|SHW-M480K|SHW-M480S|SHW-M480W|SHW-M485W|SHW-M486W|SHW-M500W|GT-I9228|SCH-P739|SCH-I925|GT-I9200|GT-P5200|GT-P5210|GT-P5210X|SM-T311|SM-T310|SM-T310X|SM-T210|SM-T210R|SM-T211|SM-P600|SM-P601|SM-P605|SM-P900|SM-P901|SM-T217|SM-T217A|SM-T217S|SM-P6000|SM-T3100|SGH-I467|XE500|SM-T110|GT-P5220|GT-I9200X|GT-N5110X|GT-N5120|SM-P905|SM-T111|SM-T2105|SM-T315|SM-T320|SM-T320X|SM-T321|SM-T520|SM-T525|SM-T530NU|SM-T230NU|SM-T330NU|SM-T900|XE500T1C|SM-P605V|SM-P905V|SM-T337V|SM-T537V|SM-T707V|SM-T807V|SM-P600X|SM-P900X|SM-T210X|SM-T230|SM-T230X|SM-T325|GT-P7503|SM-T531|SM-T330|SM-T530|SM-T705|SM-T705C|SM-T535|SM-T331|SM-T800|SM-T700|SM-T537|SM-T807|SM-P907A|SM-T337A|SM-T537A|SM-T707A|SM-T807A|SM-T237|SM-T807P|SM-P607T|SM-T217T|SM-T337T|SM-T807T|SM-T116NQ|SM-P550|SM-T350|SM-T550|SM-T9000|SM-P9000|SM-T705Y|SM-T805|GT-P3113|SM-T710|SM-T810|SM-T815|SM-T360|SM-T533|SM-T113|SM-T335|SM-T715|SM-T560|SM-T670|SM-T677|SM-T377|SM-T567|SM-T357T|SM-T555|SM-T561|SM-T713|SM-T719|SM-T813|SM-T819|SM-T580|SM-T355Y|SM-T280',
        'Kindle' => 'Kindle|Silk.*Accelerated|Android.*\b(KFOT|KFTT|KFJWI|KFJWA|KFOTE|KFSOWI|KFTHWI|KFTHWA|KFAPWI|KFAPWA|WFJWAE|KFSAWA|KFSAWI|KFASWI|KFARWI)\b',
        'SurfaceTablet' => 'Windows NT [0-9.]+; ARM;.*(Tablet|ARMBJS)',
        'HPTablet' => 'HP Slate (7|8|10)|HP ElitePad 900|hp-tablet|EliteBook.*Touch|HP 8|Slate 21|HP SlateBook 10',
        'AsusTablet' => '^.*PadFone((?!Mobile).)*$|Transformer|TF101|TF101G|TF300T|TF300TG|TF300TL|TF700T|TF700KL|TF701T|TF810C|ME171|ME301T|ME302C|ME371MG|ME370T|ME372MG|ME172V|ME173X|ME400C|Slider SL101|\bK00F\b|\bK00C\b|\bK00E\b|\bK00L\b|TX201LA|ME176C|ME102A|\bM80TA\b|ME372CL|ME560CG|ME372CG|ME302KL| K010 | K011 | K017 | K01E |ME572C|ME103K|ME170C|ME171C|\bME70C\b|ME581C|ME581CL|ME8510C|ME181C|P01Y|PO1MA|P01Z',
        'BlackBerryTablet' => 'PlayBook|RIM Tablet',
        'HTCtablet' => 'HTC_Flyer_P512|HTC Flyer|HTC Jetstream|HTC-P715a|HTC EVO View 4G|PG41200|PG09410',
        'MotorolaTablet' => 'xoom|sholest|MZ615|MZ605|MZ505|MZ601|MZ602|MZ603|MZ604|MZ606|MZ607|MZ608|MZ609|MZ615|MZ616|MZ617',
        'NookTablet' => 'Android.*Nook|NookColor|nook browser|BNRV200|BNRV200A|BNTV250|BNTV250A|BNTV400|BNTV600|LogicPD Zoom2',
        'AcerTablet' => 'Android.*; \b(A100|A101|A110|A200|A210|A211|A500|A501|A510|A511|A700|A701|W500|W500P|W501|W501P|W510|W511|W700|G100|G100W|B1-A71|B1-710|B1-711|A1-810|A1-811|A1-830)\b|W3-810|\bA3-A10\b|\bA3-A11\b|\bA3-A20\b|\bA3-A30',
        'ToshibaTablet' => 'Android.*(AT100|AT105|AT200|AT205|AT270|AT275|AT300|AT305|AT1S5|AT500|AT570|AT700|AT830)|TOSHIBA.*FOLIO',
        'LGTablet' => '\bL-06C|LG-V909|LG-V900|LG-V700|LG-V510|LG-V500|LG-V410|LG-V400|LG-VK810\b',
        'FujitsuTablet' => 'Android.*\b(F-01D|F-02F|F-05E|F-10D|M532|Q572)\b',
        'PrestigioTablet' => 'PMP3170B|PMP3270B|PMP3470B|PMP7170B|PMP3370B|PMP3570C|PMP5870C|PMP3670B|PMP5570C|PMP5770D|PMP3970B|PMP3870C|PMP5580C|PMP5880D|PMP5780D|PMP5588C|PMP7280C|PMP7280C3G|PMP7280|PMP7880D|PMP5597D|PMP5597|PMP7100D|PER3464|PER3274|PER3574|PER3884|PER5274|PER5474|PMP5097CPRO|PMP5097|PMP7380D|PMP5297C|PMP5297C_QUAD|PMP812E|PMP812E3G|PMP812F|PMP810E|PMP880TD|PMT3017|PMT3037|PMT3047|PMT3057|PMT7008|PMT5887|PMT5001|PMT5002',
        'LenovoTablet' => 'Lenovo TAB|Idea(Tab|Pad)( A1|A10| K1|)|ThinkPad([ ]+)?Tablet|YT3-X90L|YT3-X90F|YT3-X90X|Lenovo.*(S2109|S2110|S5000|S6000|K3011|A3000|A3500|A1000|A2107|A2109|A1107|A5500|A7600|B6000|B8000|B8080)(-|)(FL|F|HV|H|)',
        'DellTablet' => 'Venue 11|Venue 8|Venue 7|Dell Streak 10|Dell Streak 7',
        'YarvikTablet' => 'Android.*\b(TAB210|TAB211|TAB224|TAB250|TAB260|TAB264|TAB310|TAB360|TAB364|TAB410|TAB411|TAB420|TAB424|TAB450|TAB460|TAB461|TAB464|TAB465|TAB467|TAB468|TAB07-100|TAB07-101|TAB07-150|TAB07-151|TAB07-152|TAB07-200|TAB07-201-3G|TAB07-210|TAB07-211|TAB07-212|TAB07-214|TAB07-220|TAB07-400|TAB07-485|TAB08-150|TAB08-200|TAB08-201-3G|TAB08-201-30|TAB09-100|TAB09-211|TAB09-410|TAB10-150|TAB10-201|TAB10-211|TAB10-400|TAB10-410|TAB13-201|TAB274EUK|TAB275EUK|TAB374EUK|TAB462EUK|TAB474EUK|TAB9-200)\b',
        'MedionTablet' => 'Android.*\bOYO\b|LIFE.*(P9212|P9514|P9516|S9512)|LIFETAB',
        'ArnovaTablet' => '97G4|AN10G2|AN7bG3|AN7fG3|AN8G3|AN8cG3|AN7G3|AN9G3|AN7dG3|AN7dG3ST|AN7dG3ChildPad|AN10bG3|AN10bG3DT|AN9G2',
        'IntensoTablet' => 'INM8002KP|INM1010FP|INM805ND|Intenso Tab|TAB1004',
        'IRUTablet' => 'M702pro',
        'MegafonTablet' => 'MegaFon V9|\bZTE V9\b|Android.*\bMT7A\b',
        'EbodaTablet' => 'E-Boda (Supreme|Impresspeed|Izzycomm|Essential)',
        'AllViewTablet' => 'Allview.*(Viva|Alldro|City|Speed|All TV|Frenzy|Quasar|Shine|TX1|AX1|AX2)',
        'ArchosTablet' => '\b(101G9|80G9|A101IT)\b|Qilive 97R|Archos5|\bARCHOS (70|79|80|90|97|101|FAMILYPAD|)(b|)(G10| Cobalt| TITANIUM(HD|)| Xenon| Neon|XSK| 2| XS 2| PLATINUM| CARBON|GAMEPAD)\b',
        'AinolTablet' => 'NOVO7|NOVO8|NOVO10|Novo7Aurora|Novo7Basic|NOVO7PALADIN|novo9-Spark',
        'NokiaLumiaTablet' => 'Lumia 2520',
        'SonyTablet' => 'Sony.*Tablet|Xperia Tablet|Sony Tablet S|SO-03E|SGPT12|SGPT13|SGPT114|SGPT121|SGPT122|SGPT123|SGPT111|SGPT112|SGPT113|SGPT131|SGPT132|SGPT133|SGPT211|SGPT212|SGPT213|SGP311|SGP312|SGP321|EBRD1101|EBRD1102|EBRD1201|SGP351|SGP341|SGP511|SGP512|SGP521|SGP541|SGP551|SGP621|SGP612|SOT31',
        'PhilipsTablet' => '\b(PI2010|PI3000|PI3100|PI3105|PI3110|PI3205|PI3210|PI3900|PI4010|PI7000|PI7100)\b',
        'CubeTablet' => 'Android.*(K8GT|U9GT|U10GT|U16GT|U17GT|U18GT|U19GT|U20GT|U23GT|U30GT)|CUBE U8GT',
        'CobyTablet' => 'MID1042|MID1045|MID1125|MID1126|MID7012|MID7014|MID7015|MID7034|MID7035|MID7036|MID7042|MID7048|MID7127|MID8042|MID8048|MID8127|MID9042|MID9740|MID9742|MID7022|MID7010',
        'MIDTablet' => 'M9701|M9000|M9100|M806|M1052|M806|T703|MID701|MID713|MID710|MID727|MID760|MID830|MID728|MID933|MID125|MID810|MID732|MID120|MID930|MID800|MID731|MID900|MID100|MID820|MID735|MID980|MID130|MID833|MID737|MID960|MID135|MID860|MID736|MID140|MID930|MID835|MID733|MID4X10',
        'MSITablet' => 'MSI \b(Primo 73K|Primo 73L|Primo 81L|Primo 77|Primo 93|Primo 75|Primo 76|Primo 73|Primo 81|Primo 91|Primo 90|Enjoy 71|Enjoy 7|Enjoy 10)\b',
        'SMiTTablet' => 'Android.*(\bMID\b|MID-560|MTV-T1200|MTV-PND531|MTV-P1101|MTV-PND530)',
        'RockChipTablet' => 'Android.*(RK2818|RK2808A|RK2918|RK3066)|RK2738|RK2808A',
        'FlyTablet' => 'IQ310|Fly Vision',
        'bqTablet' => 'Android.*(bq)?.*(Elcano|Curie|Edison|Maxwell|Kepler|Pascal|Tesla|Hypatia|Platon|Newton|Livingstone|Cervantes|Avant|Aquaris [E|M]10)|Maxwell.*Lite|Maxwell.*Plus',
        'HuaweiTablet' => 'MediaPad|MediaPad 7 Youth|IDEOS S7|S7-201c|S7-202u|S7-101|S7-103|S7-104|S7-105|S7-106|S7-201|S7-Slim',
        'NecTablet' => '\bN-06D|\bN-08D',
        'PantechTablet' => 'Pantech.*P4100',
        'BronchoTablet' => 'Broncho.*(N701|N708|N802|a710)',
        'VersusTablet' => 'TOUCHPAD.*[78910]|\bTOUCHTAB\b',
        'ZyncTablet' => 'z1000|Z99 2G|z99|z930|z999|z990|z909|Z919|z900',
        'PositivoTablet' => 'TB07STA|TB10STA|TB07FTA|TB10FTA',
        'NabiTablet' => 'Android.*\bNabi',
        'KoboTablet' => 'Kobo Touch|\bK080\b|\bVox\b Build|\bArc\b Build',
        'DanewTablet' => 'DSlide.*\b(700|701R|702|703R|704|802|970|971|972|973|974|1010|1012)\b',
        'TexetTablet' => 'NaviPad|TB-772A|TM-7045|TM-7055|TM-9750|TM-7016|TM-7024|TM-7026|TM-7041|TM-7043|TM-7047|TM-8041|TM-9741|TM-9747|TM-9748|TM-9751|TM-7022|TM-7021|TM-7020|TM-7011|TM-7010|TM-7023|TM-7025|TM-7037W|TM-7038W|TM-7027W|TM-9720|TM-9725|TM-9737W|TM-1020|TM-9738W|TM-9740|TM-9743W|TB-807A|TB-771A|TB-727A|TB-725A|TB-719A|TB-823A|TB-805A|TB-723A|TB-715A|TB-707A|TB-705A|TB-709A|TB-711A|TB-890HD|TB-880HD|TB-790HD|TB-780HD|TB-770HD|TB-721HD|TB-710HD|TB-434HD|TB-860HD|TB-840HD|TB-760HD|TB-750HD|TB-740HD|TB-730HD|TB-722HD|TB-720HD|TB-700HD|TB-500HD|TB-470HD|TB-431HD|TB-430HD|TB-506|TB-504|TB-446|TB-436|TB-416|TB-146SE|TB-126SE',
        'PlaystationTablet' => 'Playstation.*(Portable|Vita)',
        'TrekstorTablet' => 'ST10416-1|VT10416-1|ST70408-1|ST702xx-1|ST702xx-2|ST80208|ST97216|ST70104-2|VT10416-2|ST10216-2A|SurfTab',
        'PyleAudioTablet' => '\b(PTBL10CEU|PTBL10C|PTBL72BC|PTBL72BCEU|PTBL7CEU|PTBL7C|PTBL92BC|PTBL92BCEU|PTBL9CEU|PTBL9CUK|PTBL9C)\b',
        'AdvanTablet' => 'Android.* \b(E3A|T3X|T5C|T5B|T3E|T3C|T3B|T1J|T1F|T2A|T1H|T1i|E1C|T1-E|T5-A|T4|E1-B|T2Ci|T1-B|T1-D|O1-A|E1-A|T1-A|T3A|T4i)\b ',
        'DanyTechTablet' => 'Genius Tab G3|Genius Tab S2|Genius Tab Q3|Genius Tab G4|Genius Tab Q4|Genius Tab G-II|Genius TAB GII|Genius TAB GIII|Genius Tab S1',
        'GalapadTablet' => 'Android.*\bG1\b',
        'MicromaxTablet' => 'Funbook|Micromax.*\b(P250|P560|P360|P362|P600|P300|P350|P500|P275)\b',
        'KarbonnTablet' => 'Android.*\b(A39|A37|A34|ST8|ST10|ST7|Smart Tab3|Smart Tab2)\b',
        'AllFineTablet' => 'Fine7 Genius|Fine7 Shine|Fine7 Air|Fine8 Style|Fine9 More|Fine10 Joy|Fine11 Wide',
        'PROSCANTablet' => '\b(PEM63|PLT1023G|PLT1041|PLT1044|PLT1044G|PLT1091|PLT4311|PLT4311PL|PLT4315|PLT7030|PLT7033|PLT7033D|PLT7035|PLT7035D|PLT7044K|PLT7045K|PLT7045KB|PLT7071KG|PLT7072|PLT7223G|PLT7225G|PLT7777G|PLT7810K|PLT7849G|PLT7851G|PLT7852G|PLT8015|PLT8031|PLT8034|PLT8036|PLT8080K|PLT8082|PLT8088|PLT8223G|PLT8234G|PLT8235G|PLT8816K|PLT9011|PLT9045K|PLT9233G|PLT9735|PLT9760G|PLT9770G)\b',
        'YONESTablet' => 'BQ1078|BC1003|BC1077|RK9702|BC9730|BC9001|IT9001|BC7008|BC7010|BC708|BC728|BC7012|BC7030|BC7027|BC7026',
        'ChangJiaTablet' => 'TPC7102|TPC7103|TPC7105|TPC7106|TPC7107|TPC7201|TPC7203|TPC7205|TPC7210|TPC7708|TPC7709|TPC7712|TPC7110|TPC8101|TPC8103|TPC8105|TPC8106|TPC8203|TPC8205|TPC8503|TPC9106|TPC9701|TPC97101|TPC97103|TPC97105|TPC97106|TPC97111|TPC97113|TPC97203|TPC97603|TPC97809|TPC97205|TPC10101|TPC10103|TPC10106|TPC10111|TPC10203|TPC10205|TPC10503',
        'GUTablet' => 'TX-A1301|TX-M9002|Q702|kf026',
        'PointOfViewTablet' => 'TAB-P506|TAB-navi-7-3G-M|TAB-P517|TAB-P-527|TAB-P701|TAB-P703|TAB-P721|TAB-P731N|TAB-P741|TAB-P825|TAB-P905|TAB-P925|TAB-PR945|TAB-PL1015|TAB-P1025|TAB-PI1045|TAB-P1325|TAB-PROTAB[0-9]+|TAB-PROTAB25|TAB-PROTAB26|TAB-PROTAB27|TAB-PROTAB26XL|TAB-PROTAB2-IPS9|TAB-PROTAB30-IPS9|TAB-PROTAB25XXL|TAB-PROTAB26-IPS10|TAB-PROTAB30-IPS10',
        'OvermaxTablet' => 'OV-(SteelCore|NewBase|Basecore|Baseone|Exellen|Quattor|EduTab|Solution|ACTION|BasicTab|TeddyTab|MagicTab|Stream|TB-08|TB-09)',
        'HCLTablet' => 'HCL.*Tablet|Connect-3G-2.0|Connect-2G-2.0|ME Tablet U1|ME Tablet U2|ME Tablet G1|ME Tablet X1|ME Tablet Y2|ME Tablet Sync',
        'DPSTablet' => 'DPS Dream 9|DPS Dual 7',
        'VistureTablet' => 'V97 HD|i75 3G|Visture V4( HD)?|Visture V5( HD)?|Visture V10',
        'CrestaTablet' => 'CTP(-)?810|CTP(-)?818|CTP(-)?828|CTP(-)?838|CTP(-)?888|CTP(-)?978|CTP(-)?980|CTP(-)?987|CTP(-)?988|CTP(-)?989',
        'MediatekTablet' => '\bMT8125|MT8389|MT8135|MT8377\b',
        'ConcordeTablet' => 'Concorde([ ]+)?Tab|ConCorde ReadMan',
        'GoCleverTablet' => 'GOCLEVER TAB|A7GOCLEVER|M1042|M7841|M742|R1042BK|R1041|TAB A975|TAB A7842|TAB A741|TAB A741L|TAB M723G|TAB M721|TAB A1021|TAB I921|TAB R721|TAB I720|TAB T76|TAB R70|TAB R76.2|TAB R106|TAB R83.2|TAB M813G|TAB I721|GCTA722|TAB I70|TAB I71|TAB S73|TAB R73|TAB R74|TAB R93|TAB R75|TAB R76.1|TAB A73|TAB A93|TAB A93.2|TAB T72|TAB R83|TAB R974|TAB R973|TAB A101|TAB A103|TAB A104|TAB A104.2|R105BK|M713G|A972BK|TAB A971|TAB R974.2|TAB R104|TAB R83.3|TAB A1042',
        'ModecomTablet' => 'FreeTAB 9000|FreeTAB 7.4|FreeTAB 7004|FreeTAB 7800|FreeTAB 2096|FreeTAB 7.5|FreeTAB 1014|FreeTAB 1001 |FreeTAB 8001|FreeTAB 9706|FreeTAB 9702|FreeTAB 7003|FreeTAB 7002|FreeTAB 1002|FreeTAB 7801|FreeTAB 1331|FreeTAB 1004|FreeTAB 8002|FreeTAB 8014|FreeTAB 9704|FreeTAB 1003',
        'VoninoTablet' => '\b(Argus[ _]?S|Diamond[ _]?79HD|Emerald[ _]?78E|Luna[ _]?70C|Onyx[ _]?S|Onyx[ _]?Z|Orin[ _]?HD|Orin[ _]?S|Otis[ _]?S|SpeedStar[ _]?S|Magnet[ _]?M9|Primus[ _]?94[ _]?3G|Primus[ _]?94HD|Primus[ _]?QS|Android.*\bQ8\b|Sirius[ _]?EVO[ _]?QS|Sirius[ _]?QS|Spirit[ _]?S)\b',
        'ECSTablet' => 'V07OT2|TM105A|S10OT1|TR10CS1',
        'StorexTablet' => 'eZee[_\']?(Tab|Go)[0-9]+|TabLC7|Looney Tunes Tab',
        'VodafoneTablet' => 'SmartTab([ ]+)?[0-9]+|SmartTabII10|SmartTabII7|VF-1497',
        'EssentielBTablet' => 'Smart[ \']?TAB[ ]+?[0-9]+|Family[ \']?TAB2',
        'RossMoorTablet' => 'RM-790|RM-997|RMD-878G|RMD-974R|RMT-705A|RMT-701|RME-601|RMT-501|RMT-711',
        'iMobileTablet' => 'i-mobile i-note',
        'TolinoTablet' => 'tolino tab [0-9.]+|tolino shine',
        'AudioSonicTablet' => '\bC-22Q|T7-QC|T-17B|T-17P\b',
        'AMPETablet' => 'Android.* A78 ',
        'SkkTablet' => 'Android.* (SKYPAD|PHOENIX|CYCLOPS)',
        'TecnoTablet' => 'TECNO P9',
        'JXDTablet' => 'Android.* \b(F3000|A3300|JXD5000|JXD3000|JXD2000|JXD300B|JXD300|S5800|S7800|S602b|S5110b|S7300|S5300|S602|S603|S5100|S5110|S601|S7100a|P3000F|P3000s|P101|P200s|P1000m|P200m|P9100|P1000s|S6600b|S908|P1000|P300|S18|S6600|S9100)\b',
        'iJoyTablet' => 'Tablet (Spirit 7|Essentia|Galatea|Fusion|Onix 7|Landa|Titan|Scooby|Deox|Stella|Themis|Argon|Unique 7|Sygnus|Hexen|Finity 7|Cream|Cream X2|Jade|Neon 7|Neron 7|Kandy|Scape|Saphyr 7|Rebel|Biox|Rebel|Rebel 8GB|Myst|Draco 7|Myst|Tab7-004|Myst|Tadeo Jones|Tablet Boing|Arrow|Draco Dual Cam|Aurix|Mint|Amity|Revolution|Finity 9|Neon 9|T9w|Amity 4GB Dual Cam|Stone 4GB|Stone 8GB|Andromeda|Silken|X2|Andromeda II|Halley|Flame|Saphyr 9,7|Touch 8|Planet|Triton|Unique 10|Hexen 10|Memphis 4GB|Memphis 8GB|Onix 10)',
        'FX2Tablet' => 'FX2 PAD7|FX2 PAD10',
        'XoroTablet' => 'KidsPAD 701|PAD[ ]?712|PAD[ ]?714|PAD[ ]?716|PAD[ ]?717|PAD[ ]?718|PAD[ ]?720|PAD[ ]?721|PAD[ ]?722|PAD[ ]?790|PAD[ ]?792|PAD[ ]?900|PAD[ ]?9715D|PAD[ ]?9716DR|PAD[ ]?9718DR|PAD[ ]?9719QR|PAD[ ]?9720QR|TelePAD1030|Telepad1032|TelePAD730|TelePAD731|TelePAD732|TelePAD735Q|TelePAD830|TelePAD9730|TelePAD795|MegaPAD 1331|MegaPAD 1851|MegaPAD 2151',
        'ViewsonicTablet' => 'ViewPad 10pi|ViewPad 10e|ViewPad 10s|ViewPad E72|ViewPad7|ViewPad E100|ViewPad 7e|ViewSonic VB733|VB100a',
        'OdysTablet' => 'LOOX|XENO10|ODYS[ -](Space|EVO|Xpress|NOON)|\bXELIO\b|Xelio10Pro|XELIO7PHONETAB|XELIO10EXTREME|XELIOPT2|NEO_QUAD10',
        'CaptivaTablet' => 'CAPTIVA PAD',
        'IconbitTablet' => 'NetTAB|NT-3702|NT-3702S|NT-3702S|NT-3603P|NT-3603P|NT-0704S|NT-0704S|NT-3805C|NT-3805C|NT-0806C|NT-0806C|NT-0909T|NT-0909T|NT-0907S|NT-0907S|NT-0902S|NT-0902S',
        'TeclastTablet' => 'T98 4G|\bP80\b|\bX90HD\b|X98 Air|X98 Air 3G|\bX89\b|P80 3G|\bX80h\b|P98 Air|\bX89HD\b|P98 3G|\bP90HD\b|P89 3G|X98 3G|\bP70h\b|P79HD 3G|G18d 3G|\bP79HD\b|\bP89s\b|\bA88\b|\bP10HD\b|\bP19HD\b|G18 3G|\bP78HD\b|\bA78\b|\bP75\b|G17s 3G|G17h 3G|\bP85t\b|\bP90\b|\bP11\b|\bP98t\b|\bP98HD\b|\bG18d\b|\bP85s\b|\bP11HD\b|\bP88s\b|\bA80HD\b|\bA80se\b|\bA10h\b|\bP89\b|\bP78s\b|\bG18\b|\bP85\b|\bA70h\b|\bA70\b|\bG17\b|\bP18\b|\bA80s\b|\bA11s\b|\bP88HD\b|\bA80h\b|\bP76s\b|\bP76h\b|\bP98\b|\bA10HD\b|\bP78\b|\bP88\b|\bA11\b|\bA10t\b|\bP76a\b|\bP76t\b|\bP76e\b|\bP85HD\b|\bP85a\b|\bP86\b|\bP75HD\b|\bP76v\b|\bA12\b|\bP75a\b|\bA15\b|\bP76Ti\b|\bP81HD\b|\bA10\b|\bT760VE\b|\bT720HD\b|\bP76\b|\bP73\b|\bP71\b|\bP72\b|\bT720SE\b|\bC520Ti\b|\bT760\b|\bT720VE\b|T720-3GE|T720-WiFi',
        'OndaTablet' => '\b(V975i|Vi30|VX530|V701|Vi60|V701s|Vi50|V801s|V719|Vx610w|VX610W|V819i|Vi10|VX580W|Vi10|V711s|V813|V811|V820w|V820|Vi20|V711|VI30W|V712|V891w|V972|V819w|V820w|Vi60|V820w|V711|V813s|V801|V819|V975s|V801|V819|V819|V818|V811|V712|V975m|V101w|V961w|V812|V818|V971|V971s|V919|V989|V116w|V102w|V973|Vi40)\b[\s]+',
        'JaytechTablet' => 'TPC-PA762',
        'BlaupunktTablet' => 'Endeavour 800NG|Endeavour 1010',
        'DigmaTablet' => '\b(iDx10|iDx9|iDx8|iDx7|iDxD7|iDxD8|iDsQ8|iDsQ7|iDsQ8|iDsD10|iDnD7|3TS804H|iDsQ11|iDj7|iDs10)\b',
        'EvolioTablet' => 'ARIA_Mini_wifi|Aria[ _]Mini|Evolio X10|Evolio X7|Evolio X8|\bEvotab\b|\bNeura\b',
        'LavaTablet' => 'QPAD E704|\bIvoryS\b|E-TAB IVORY|\bE-TAB\b',
        'AocTablet' => 'MW0811|MW0812|MW0922|MTK8382|MW1031|MW0831|MW0821|MW0931|MW0712',
        'MpmanTablet' => 'MP11 OCTA|MP10 OCTA|MPQC1114|MPQC1004|MPQC994|MPQC974|MPQC973|MPQC804|MPQC784|MPQC780|\bMPG7\b|MPDCG75|MPDCG71|MPDC1006|MP101DC|MPDC9000|MPDC905|MPDC706HD|MPDC706|MPDC705|MPDC110|MPDC100|MPDC99|MPDC97|MPDC88|MPDC8|MPDC77|MP709|MID701|MID711|MID170|MPDC703|MPQC1010',
        'CelkonTablet' => 'CT695|CT888|CT[\s]?910|CT7 Tab|CT9 Tab|CT3 Tab|CT2 Tab|CT1 Tab|C820|C720|\bCT-1\b',
        'WolderTablet' => 'miTab \b(DIAMOND|SPACE|BROOKLYN|NEO|FLY|MANHATTAN|FUNK|EVOLUTION|SKY|GOCAR|IRON|GENIUS|POP|MINT|EPSILON|BROADWAY|JUMP|HOP|LEGEND|NEW AGE|LINE|ADVANCE|FEEL|FOLLOW|LIKE|LINK|LIVE|THINK|FREEDOM|CHICAGO|CLEVELAND|BALTIMORE-GH|IOWA|BOSTON|SEATTLE|PHOENIX|DALLAS|IN 101|MasterChef)\b',
        'MiTablet' => '\bMI PAD\b|\bHM NOTE 1W\b',
        'NibiruTablet' => 'Nibiru M1|Nibiru Jupiter One',
        'NexoTablet' => 'NEXO NOVA|NEXO 10|NEXO AVIO|NEXO FREE|NEXO GO|NEXO EVO|NEXO 3G|NEXO SMART|NEXO KIDDO|NEXO MOBI',
        'LeaderTablet' => 'TBLT10Q|TBLT10I|TBL-10WDKB|TBL-10WDKBO2013|TBL-W230V2|TBL-W450|TBL-W500|SV572|TBLT7I|TBA-AC7-8G|TBLT79|TBL-8W16|TBL-10W32|TBL-10WKB|TBL-W100',
        'UbislateTablet' => 'UbiSlate[\s]?7C',
        'PocketBookTablet' => 'Pocketbook',
        'KocasoTablet' => '\b(TB-1207)\b',
        'HisenseTablet' => '\b(F5281|E2371)\b',
        'Hudl' => 'Hudl HT7S3|Hudl 2',
        'TelstraTablet' => 'T-Hub2',
        'GenericTablet' => 'Android.*\b97D\b|Tablet(?!.*PC)|BNTV250A|MID-WCDMA|LogicPD Zoom2|\bA7EB\b|CatNova8|A1_07|CT704|CT1002|\bM721\b|rk30sdk|\bEVOTAB\b|M758A|ET904|ALUMIUM10|Smartfren Tab|Endeavour 1010|Tablet-PC-4|Tagi Tab|\bM6pro\b|CT1020W|arc 10HD|\bTP750\b');
    protected static $operatingSystems = array(
        'AndroidOS' => 'Android',
        'BlackBerryOS' => 'blackberry|\bBB10\b|rim tablet os',
        'PalmOS' => 'PalmOS|avantgo|blazer|elaine|hiptop|palm|plucker|xiino',
        'SymbianOS' => 'Symbian|SymbOS|Series60|Series40|SYB-[0-9]+|\bS60\b',
        'WindowsMobileOS' => 'Windows CE.*(PPC|Smartphone|Mobile|[0-9]{3}x[0-9]{3})|Window Mobile|Windows Phone [0-9.]+|WCE;',
        'WindowsPhoneOS' => 'Windows Phone 10.0|Windows Phone 8.1|Windows Phone 8.0|Windows Phone OS|XBLWP7|ZuneWP7|Windows NT 6.[23]; ARM;',
        'iOS' => '\biPhone.*Mobile|\biPod|\biPad',
        'MeeGoOS' => 'MeeGo',
        'MaemoOS' => 'Maemo',
        'JavaOS' => 'J2ME/|\bMIDP\b|\bCLDC\b',
        'webOS' => 'webOS|hpwOS',
        'badaOS' => '\bBada\b',
        'BREWOS' => 'BREW',);
    protected static $browsers = array(
        'Chrome' => '\bCrMo\b|CriOS|Android.*Chrome/[.0-9]* (Mobile)?',
        'Dolfin' => '\bDolfin\b',
        'Opera' => 'Opera.*Mini|Opera.*Mobi|Android.*Opera|Mobile.*OPR/[0-9.]+|Coast/[0-9.]+',
        'Skyfire' => 'Skyfire',
        'Edge' => 'Mobile Safari/[.0-9]* Edge',
        'IE' => 'IEMobile|MSIEMobile',
        'Firefox' => 'fennec|firefox.*maemo|(Mobile|Tablet).*Firefox|Firefox.*Mobile|FxiOS',
        'Bolt' => 'bolt',
        'TeaShark' => 'teashark',
        'Blazer' => 'Blazer',
        'Safari' => 'Version.*Mobile.*Safari|Safari.*Mobile|MobileSafari',
        'UCBrowser' => 'UC.*Browser|UCWEB',
        'baiduboxapp' => 'baiduboxapp',
        'baidubrowser' => 'baidubrowser',
        'DiigoBrowser' => 'DiigoBrowser',
        'Puffin' => 'Puffin',
        'Mercury' => '\bMercury\b',
        'ObigoBrowser' => 'Obigo',
        'NetFront' => 'NF-Browser',
        'GenericBrowser' => 'NokiaBrowser|OviBrowser|OneBrowser|TwonkyBeamBrowser|SEMC.*Browser|FlyFlow|Minimo|NetFront|Novarra-Vision|MQQBrowser|MicroMessenger',
        'PaleMoon' => 'Android.*PaleMoon|Mobile.*PaleMoon',);
    protected static $utilities = array(
        'Bot' => 'Googlebot|facebookexternalhit|AdsBot-Google|Google Keyword Suggestion|Facebot|YandexBot|YandexMobileBot|bingbot|ia_archiver|AhrefsBot|Ezooms|GSLFbot|WBSearchBot|Twitterbot|TweetmemeBot|Twikle|PaperLiBot|Wotbox|UnwindFetchor|Exabot|MJ12bot|YandexImages|TurnitinBot|Pingdom',
        'MobileBot' => 'Googlebot-Mobile|AdsBot-Google-Mobile|YahooSeeker/M1A1-R2D2',
        'DesktopMode' => 'WPDesktop',
        'TV' => 'SonyDTV|HbbTV',
        'WebKit' => '(webkit)[ /]([\w.]+)',
        'Console' => '\b(Nintendo|Nintendo WiiU|Nintendo 3DS|PLAYSTATION|Xbox)\b',
        'Watch' => 'SM-V700',);
    protected static $uaHttpHeaders = array(
        'HTTP_USER_AGENT',
        'HTTP_X_OPERAMINI_PHONE_UA',
        'HTTP_X_DEVICE_USER_AGENT',
        'HTTP_X_ORIGINAL_USER_AGENT',
        'HTTP_X_SKYFIRE_PHONE',
        'HTTP_X_BOLT_PHONE_UA',
        'HTTP_DEVICE_STOCK_UA',
        'HTTP_X_UCBROWSER_DEVICE_UA');
    protected static $properties = array(
        'Mobile' => 'Mobile/[VER]',
        'Build' => 'Build/[VER]',
        'Version' => 'Version/[VER]',
        'VendorID' => 'VendorID/[VER]',
        'iPad' => 'iPad.*CPU[a-z ]+[VER]',
        'iPhone' => 'iPhone.*CPU[a-z ]+[VER]',
        'iPod' => 'iPod.*CPU[a-z ]+[VER]',
        'Kindle' => 'Kindle/[VER]',
        'Chrome' => array('Chrome/[VER]', 'CriOS/[VER]', 'CrMo/[VER]'),
        'Coast' => array('Coast/[VER]'),
        'Dolfin' => 'Dolfin/[VER]',
        'Firefox' => array('Firefox/[VER]', 'FxiOS/[VER]'),
        'Fennec' => 'Fennec/[VER]',
        'Edge' => 'Edge/[VER]',
        'IE' => array('IEMobile/[VER];', 'IEMobile [VER]', 'MSIE [VER];', 'Trident/[0-9.]+;.*rv:[VER]'),
        'NetFront' => 'NetFront/[VER]',
        'NokiaBrowser' => 'NokiaBrowser/[VER]',
        'Opera' => array( ' OPR/[VER]', 'Opera Mini/[VER]', 'Version/[VER]' ),
        'Opera Mini' => 'Opera Mini/[VER]',
        'Opera Mobi' => 'Version/[VER]',
        'UC Browser' => 'UC Browser[VER]',
        'MQQBrowser' => 'MQQBrowser/[VER]',
        'MicroMessenger' => 'MicroMessenger/[VER]',
        'baiduboxapp' => 'baiduboxapp/[VER]',
        'baidubrowser' => 'baidubrowser/[VER]',
        'SamsungBrowser' => 'SamsungBrowser/[VER]',
        'Iron' => 'Iron/[VER]',
        'Safari' => array( 'Version/[VER]', 'Safari/[VER]' ),
        'Skyfire' => 'Skyfire/[VER]',
        'Tizen' => 'Tizen/[VER]',
        'Webkit' => 'webkit[ /][VER]',
        'PaleMoon' => 'PaleMoon/[VER]',
        'Gecko' => 'Gecko/[VER]',
        'Trident' => 'Trident/[VER]',
        'Presto' => 'Presto/[VER]',
        'Goanna' => 'Goanna/[VER]',
        'iOS' => ' \bi?OS\b [VER][ ;]{1}',
        'Android' => 'Android [VER]',
        'BlackBerry' => array('BlackBerry[\w]+/[VER]', 'BlackBerry.*Version/[VER]', 'Version/[VER]'),
        'BREW' => 'BREW [VER]',
        'Java' => 'Java/[VER]',
        'Windows Phone OS' => array( 'Windows Phone OS [VER]', 'Windows Phone [VER]'),
        'Windows Phone' => 'Windows Phone [VER]',
        'Windows CE' => 'Windows CE/[VER]',
        'Windows NT' => 'Windows NT [VER]',
        'Symbian' => array('SymbianOS/[VER]', 'Symbian/[VER]'),
        'webOS' => array('webOS/[VER]', 'hpwOS/[VER];'),);
    public function __construct(
        array $headers = null,
        $userAgent = null
    ) {
        $this->setHttpHeaders($headers);
        $this->setUserAgent($userAgent);}
    public static function getScriptVersion()
    {
        return self::VERSION;}
    public function setHttpHeaders($httpHeaders = null)
    {
        if (!is_array($httpHeaders) || !count($httpHeaders)) {
            $httpHeaders = $_SERVER;}
        $this->httpHeaders = array();
        foreach ($httpHeaders as $key => $value) {
            if (substr($key, 0, 5) === 'HTTP_') {
                $this->httpHeaders[$key] = $value;}}
        $this->setCfHeaders($httpHeaders);}
    public function getHttpHeaders()
    {
        return $this->httpHeaders;}
    public function getHttpHeader($header)
    {
        if (strpos($header, '_') === false) {
            $header = str_replace('-', '_', $header);
            $header = strtoupper($header);}
        $altHeader = 'HTTP_' . $header;
        if (isset($this->httpHeaders[$header])) {
            return $this->httpHeaders[$header];
        } elseif (isset($this->httpHeaders[$altHeader])) {
            return $this->httpHeaders[$altHeader];}
        return null;}
    public function getMobileHeaders()
    {
        return self::$mobileHeaders;}
    public function getUaHttpHeaders()
    {
        return self::$uaHttpHeaders;}
    public function setCfHeaders($cfHeaders = null) {
        if (!is_array($cfHeaders) || !count($cfHeaders)) {
            $cfHeaders = $_SERVER;}
        $this->cloudfrontHeaders = array();
        $response = false;
        foreach ($cfHeaders as $key => $value) {
            if (substr(strtolower($key), 0, 16) === 'http_cloudfront_') {
                $this->cloudfrontHeaders[strtoupper($key)] = $value;
                $response = true;}}
        return $response;}
    public function getCfHeaders()
    {
        return $this->cloudfrontHeaders;}
    public function setUserAgent($userAgent = null)
    {
        $this->cache = array();
        if (false === empty($userAgent)) {
            return $this->userAgent = $userAgent;
        } else {
            $this->userAgent = null;
            foreach ($this->getUaHttpHeaders() as $altHeader) {
                if (false === empty($this->httpHeaders[$altHeader])) {
                    $this->userAgent .= $this->httpHeaders[$altHeader] . " ";}}
            if (!empty($this->userAgent)) {
                return $this->userAgent = trim($this->userAgent);}}
        if (count($this->getCfHeaders()) > 0) {
            return $this->userAgent = 'Amazon CloudFront';}
        return $this->userAgent = null;}
    public function getUserAgent()
    {
        return $this->userAgent;}
    public function setDetectionType($type = null)
    {
        if ($type === null) {
            $type = self::DETECTION_TYPE_MOBILE;}
        if ($type !== self::DETECTION_TYPE_MOBILE && $type !== self::DETECTION_TYPE_EXTENDED) {
            return;}
        $this->detectionType = $type;}
    public function getMatchingRegex()
    {
        return $this->matchingRegex;}
    public function getMatchesArray()
    {
        return $this->matchesArray;}
    public static function getPhoneDevices()
    {
        return self::$phoneDevices;}
    public static function getTabletDevices()
    {
        return self::$tabletDevices;}
    public static function getUserAgents()
    {
        return self::getBrowsers();}
    public static function getBrowsers()
    {
        return self::$browsers;}
    public static function getUtilities()
    {
        return self::$utilities;}
    public static function getMobileDetectionRules()
    {
        static $rules;
        if (!$rules) {
            $rules = array_merge(
                self::$phoneDevices,
                self::$tabletDevices,
                self::$operatingSystems,
                self::$browsers);}
        return $rules;}
    public function getMobileDetectionRulesExtended()
    {
        static $rules;
        if (!$rules) {
            $rules = array_merge(
                self::$phoneDevices,
                self::$tabletDevices,
                self::$operatingSystems,
                self::$browsers,
                self::$utilities);}
        return $rules;}
    public function getRules()
    {
        if ($this->detectionType == self::DETECTION_TYPE_EXTENDED) {
            return self::getMobileDetectionRulesExtended();
        } else {
            return self::getMobileDetectionRules();}}
    public static function getOperatingSystems()
    {
        return self::$operatingSystems;}
    public function checkHttpHeadersForMobile()
    {
        foreach ($this->getMobileHeaders() as $mobileHeader => $matchType) {
            if (isset($this->httpHeaders[$mobileHeader])) {
                if (is_array($matchType['matches'])) {
                    foreach ($matchType['matches'] as $_match) {
                        if (strpos($this->httpHeaders[$mobileHeader], $_match) !== false) {
                            return true;}}
                    return false;
                } else {
                    return true;}}}
        return false;}
    public function __call($name, $arguments)
    {
        if (substr($name, 0, 2) !== 'is') {
            throw new BadMethodCallException("No such method exists: $name");}
        $this->setDetectionType(self::DETECTION_TYPE_MOBILE);
        $key = substr($name, 2);
        return $this->matchUAAgainstKey($key);}
    protected function matchDetectionRulesAgainstUA($userAgent = null)
    {
        foreach ($this->getRules() as $_regex) {
            if (empty($_regex)) {
                continue;}
            if ($this->match($_regex, $userAgent)) {
                return true;}}
        return false;}
    protected function matchUAAgainstKey($key)
    {
        $key = strtolower($key);
        if (false === isset($this->cache[$key])) {
            $_rules = array_change_key_case($this->getRules());
            if (false === empty($_rules[$key])) {
                $this->cache[$key] = $this->match($_rules[$key]);}
            if (false === isset($this->cache[$key])) {
                $this->cache[$key] = false;}}
        return $this->cache[$key];}
    public function isMobile($userAgent = null, $httpHeaders = null)
    {
        if ($httpHeaders) {
            $this->setHttpHeaders($httpHeaders);}
        if ($userAgent) {
            $this->setUserAgent($userAgent);}
        if ($this->getUserAgent() === 'Amazon CloudFront') {
            $cfHeaders = $this->getCfHeaders();
            if(array_key_exists('HTTP_CLOUDFRONT_IS_MOBILE_VIEWER', $cfHeaders) && $cfHeaders['HTTP_CLOUDFRONT_IS_MOBILE_VIEWER'] === 'true') {
                return true;}}
        $this->setDetectionType(self::DETECTION_TYPE_MOBILE);
        if ($this->checkHttpHeadersForMobile()) {
            return true;
        } else {
            return $this->matchDetectionRulesAgainstUA();}}
    public function isTablet($userAgent = null, $httpHeaders = null)
    {
        if ($this->getUserAgent() === 'Amazon CloudFront') {
            $cfHeaders = $this->getCfHeaders();
            if(array_key_exists('HTTP_CLOUDFRONT_IS_TABLET_VIEWER', $cfHeaders) && $cfHeaders['HTTP_CLOUDFRONT_IS_TABLET_VIEWER'] === 'true') {
                return true;}}
        $this->setDetectionType(self::DETECTION_TYPE_MOBILE);
        foreach (self::$tabletDevices as $_regex) {
            if ($this->match($_regex, $userAgent)) {
                return true;}}
        return false;}
    public function is($key, $userAgent = null, $httpHeaders = null)
    {
        if ($httpHeaders) {
            $this->setHttpHeaders($httpHeaders);}
        if ($userAgent) {
            $this->setUserAgent($userAgent);}
        $this->setDetectionType(self::DETECTION_TYPE_EXTENDED);
        return $this->matchUAAgainstKey($key);}
    public function match($regex, $userAgent = null)
    {
        $match = (bool) preg_match(sprintf('#%s#is', $regex), (false === empty($userAgent) ? $userAgent : $this->userAgent), $matches);
        if ($match) {
            $this->matchingRegex = $regex;
            $this->matchesArray = $matches;}
        return $match;}
    public static function getProperties()
    {
        return self::$properties;}
    public function prepareVersionNo($ver)
    {
        $ver = str_replace(array('_', ' ', '/'), '.', $ver);
        $arrVer = explode('.', $ver, 2);
        if (isset($arrVer[1])) {
            $arrVer[1] = @str_replace('.', '', $arrVer[1]);}
        return (float) implode('.', $arrVer);}
    public function version($propertyName, $type = self::VERSION_TYPE_STRING)
    {
        if (empty($propertyName)) {
            return false;}
        if ($type !== self::VERSION_TYPE_STRING && $type !== self::VERSION_TYPE_FLOAT) {
            $type = self::VERSION_TYPE_STRING;}
        $properties = self::getProperties();
        if (true === isset($properties[$propertyName])) {
            $properties[$propertyName] = (array) $properties[$propertyName];
            foreach ($properties[$propertyName] as $propertyMatchString) {
                $propertyPattern = str_replace('[VER]', self::VER, $propertyMatchString);
                preg_match(sprintf('#%s#is', $propertyPattern), $this->userAgent, $match);
                if (false === empty($match[1])) {
                    $version = ($type == self::VERSION_TYPE_FLOAT ? $this->prepareVersionNo($match[1]) : $match[1]);
                    return $version;}}}
        return false;}
    public function mobileGrade()
    {
        $isMobile = $this->isMobile();
        if (
            $this->is('iOS') && $this->version('iPad', self::VERSION_TYPE_FLOAT) >= 4.3 ||
            $this->is('iOS') && $this->version('iPhone', self::VERSION_TYPE_FLOAT) >= 4.3 ||
            $this->is('iOS') && $this->version('iPod', self::VERSION_TYPE_FLOAT) >= 4.3 ||
            ( $this->version('Android', self::VERSION_TYPE_FLOAT)>2.1 && $this->is('Webkit') ) ||
            $this->version('Windows Phone OS', self::VERSION_TYPE_FLOAT) >= 7.5 ||
            $this->is('BlackBerry') && $this->version('BlackBerry', self::VERSION_TYPE_FLOAT) >= 6.0 ||
            $this->match('Playbook.*Tablet') ||
            ( $this->version('webOS', self::VERSION_TYPE_FLOAT) >= 1.4 && $this->match('Palm|Pre|Pixi') ) ||
            $this->match('hp.*TouchPad') ||
            ( $this->is('Firefox') && $this->version('Firefox', self::VERSION_TYPE_FLOAT) >= 18 ) ||
            ( $this->is('Chrome') && $this->is('AndroidOS') && $this->version('Android', self::VERSION_TYPE_FLOAT) >= 4.0 ) ||
            ( $this->is('Skyfire') && $this->version('Skyfire', self::VERSION_TYPE_FLOAT) >= 4.1 && $this->is('AndroidOS') && $this->version('Android', self::VERSION_TYPE_FLOAT) >= 2.3 ) ||
            ( $this->is('Opera') && $this->version('Opera Mobi', self::VERSION_TYPE_FLOAT) >= 11.5 && $this->is('AndroidOS') ) ||
            $this->is('MeeGoOS') ||
            $this->is('Tizen') ||
            $this->is('Dolfin') && $this->version('Bada', self::VERSION_TYPE_FLOAT) >= 2.0 ||
            ( ($this->is('UC Browser') || $this->is('Dolfin')) && $this->version('Android', self::VERSION_TYPE_FLOAT) >= 2.3 ) ||
            ( $this->match('Kindle Fire') ||
                $this->is('Kindle') && $this->version('Kindle', self::VERSION_TYPE_FLOAT) >= 3.0 ) ||
            $this->is('AndroidOS') && $this->is('NookTablet') ||
            $this->version('Chrome', self::VERSION_TYPE_FLOAT) >= 16 && !$isMobile ||
            $this->version('Safari', self::VERSION_TYPE_FLOAT) >= 5.0 && !$isMobile ||
            $this->version('Firefox', self::VERSION_TYPE_FLOAT) >= 10.0 && !$isMobile ||
            $this->version('IE', self::VERSION_TYPE_FLOAT) >= 7.0 && !$isMobile ||
            $this->version('Opera', self::VERSION_TYPE_FLOAT) >= 10 && !$isMobile){
            return self::MOBILE_GRADE_A;}
        if (
            $this->is('iOS') && $this->version('iPad', self::VERSION_TYPE_FLOAT)<4.3 ||
            $this->is('iOS') && $this->version('iPhone', self::VERSION_TYPE_FLOAT)<4.3 ||
            $this->is('iOS') && $this->version('iPod', self::VERSION_TYPE_FLOAT)<4.3 ||
            $this->is('Blackberry') && $this->version('BlackBerry', self::VERSION_TYPE_FLOAT) >= 5 && $this->version('BlackBerry', self::VERSION_TYPE_FLOAT)<6 ||
            ($this->version('Opera Mini', self::VERSION_TYPE_FLOAT) >= 5.0 && $this->version('Opera Mini', self::VERSION_TYPE_FLOAT) <= 7.0 &&
                ($this->version('Android', self::VERSION_TYPE_FLOAT) >= 2.3 || $this->is('iOS')) ) ||
            $this->match('NokiaN8|NokiaC7|N97.*Series60|Symbian/3') ||
            $this->version('Opera Mobi', self::VERSION_TYPE_FLOAT) >= 11 && $this->is('SymbianOS')){
            return self::MOBILE_GRADE_B;}
        if (
            $this->version('BlackBerry', self::VERSION_TYPE_FLOAT) <= 5.0 ||
            $this->match('MSIEMobile|Windows CE.*Mobile') || $this->version('Windows Mobile', self::VERSION_TYPE_FLOAT) <= 5.2 ||
            $this->is('iOS') && $this->version('iPad', self::VERSION_TYPE_FLOAT) <= 3.2 ||
            $this->is('iOS') && $this->version('iPhone', self::VERSION_TYPE_FLOAT) <= 3.2 ||
            $this->is('iOS') && $this->version('iPod', self::VERSION_TYPE_FLOAT) <= 3.2 ||
            $this->version('IE', self::VERSION_TYPE_FLOAT) <= 7.0 && !$isMobile){
            return self::MOBILE_GRADE_C;}
        return self::MOBILE_GRADE_C;}}



$MTPS->Device = new Mobile_Detect();
$MTPS->ClientLayout = ($MTPS->Device->isMobile() ? ($MTPS->Device->isTablet() ? 2 : 3) : 1);
$MTPS->RealClientLayout = $MTPS->ClientLayout;
function SmartLink($text,$url,$onclick,$id="",$class="",$style="") {
    if($onclick != "") { $onclick = " onclick=\"$onclick return false;\""; }
    if($class != "") { $class = " class=\"$class\""; }
    if($style != "") { $style = " style=\"$style\""; }
    if($id != "") { $id = " id=\"$id\""; }
    $str = "<a href=\"$url\"$onclick$class$style$id>$text</a>";
    return $str;}
function SmartLinkEx($text,$url,$data="") {
    $id = "";
    $style = "";
    $class = "";
    $onclick = "";
    $onmouseout = "";
    $onmouseover = "";
    if(IsSet($data) && $data != "") {
        if(IsSet($data['ID']) && $data['ID'] != "") { $id = " id=\"".$data['ID']."\""; }
        if(IsSet($data['Style']) && $data['Style'] != "") { $style = " style=\"".$data['Style']."\""; }
        if(IsSet($data['ClassName']) && $data['ClassName'] != "") { $class = " class=\"".$data['ClassName']."\""; }
        if(IsSet($data['OnClick']) && $data['OnClick'] != "") { $onclick = " onclick=\"".$data['OnClick']." return false;\""; }
        if(IsSet($data['OnMouseOut']) && $data['OnMouseOut'] != "") { $onmouseout = " onmouseout=\"".$data['OnMouseOut']." return false;\""; }
        if(IsSet($data['OnMouseOver']) && $data['OnMouseOver'] != "") { $onmouseover = " onmouseover=\"".$data['OnMouseOver']." return false;\""; }}
    $str = "<a href=\"$url\"$onclick$onmouseover$onmouseout$id$class$style>$text</a>";
    return $str;}
function RemoveIndexLink($link) {
    if(($pos = strpos(strtolower($link),strtolower($GLOBALS['urlWEB']))) !== false) {
        if($pos == 0) {
            if(($pos2 = strpos(strtolower($link),"/index.php")) !== false) {
                $link = str_replace("/index.php","/",$link);}}}
    return $link;}
function TranslateLink($link,$language,$translate_from_pages_db=false) {
    global $MTPS, $TEXTS, $Web, $DB;
    $count = 0;
    $arr = explode('/',$link);
    $new_link = "";
    foreach($arr as $key => $val) {
        if($count > 2) {
            if($val != "") {
                $val2 = $val;
                foreach($TEXTS as $lng_key => $lng_val) {
                    if(strpos($lng_key,"url") === 0) {
                        $found = false;
                        foreach($lng_val as $trans_key => $trans_val) {
                            if($trans_val == $val) { $found = true; break; }}
                        if($found) {
                            if(IsSet($lng_val[$language])) { $val2 = $lng_val[$language]; } else { $val2 = $lng_val[$MTPS->DefaultLanguage]; }}}
                    else {
                        break;}}
                $new_link.= $val2."/";}}
        else {
            $new_link.= $val."/";}
        $count++;}
    return $new_link;}
function CreateLink($link,$language="",$kotva="",$kotva_v_odkazu="",$msg=false,$translate_from_pages_db=false) {
    global $MTPS;
    $delic = '?';
    if($language == "") { $language = $MTPS->Language; }
    $pos = strpos($link,"?");
    if($pos !== false) { $dl = $pos; }
    else { $dl = strlen($link); }
    $link1 = substr($link,0,$dl);
    $link3 = substr($link,$dl);
    $link2 = "";
    $link2 = TestLink($link1);
    $link1 = RemoveIndexLink($link1);
    $link1 = TranslateLink($link1,$language,$translate_from_pages_db);
    $link = $link1.$link2.$link3;
    $link = str_replace("//","/",$link);
    $link = str_replace("https:/","https://",$link);
    $link = str_replace("https:///","https://",$link);
    $link = str_replace("http:/","http://",$link);
    $link = str_replace("http:///","http://",$link);
    $link = LanguageLink($link,$language);
    $Odkaz = $link.$kotva;
    if(!$msg) {
        $Odkaz = DeleteParam($Odkaz,"msg");}
    return $Odkaz;}
function WriteLink($styl,$text,$link,$hint="",$pomocny_styl="",$kotva="",$kotva_v_odkazu="") {
    $full_link = CreateLink($link,$kotva,$kotva_v_odkazu);
    if($pomocny_styl != "") { $style = 'style="'.$pomocny_styl.'" '; }
    if($styl != "") { $styl = ' class="'.$styl.'"'; } else { $styl = ""; }
    if($hint != "") { $hint = ' title="'.$hint.'"'; } else { $hint = ""; }
    $style = "";
    $Odkaz = '<a'.$styl.' '.$kotva_v_odkazu.''.$style.'href="'.$full_link.'"'.$hint.'>'.$text.'</a>';
    return $Odkaz;}
function AddParam($link,$parametr,$hodnota) {
    $link = DeleteParam($link,$parametr);
    $delic = "?";
    if(($pos = strpos($link,"?"))!== false) {
        if($pos < (strlen($link)-1)) { $delic = "&"; }}
    $Odkaz = $link.$delic.$parametr."=".$hodnota;
    return $Odkaz;}
function DeleteParam($link,$parametr,$test=false) {
    $dl = strlen($link);
    $NewLink = $link;
    $ActionLinkPos = strpos($link,"ActionLink=",0);
    $delic = "";
    if(($pos = strpos($link,"?".$parametr."=",0)) !== false) { $delic = "?"; }
    if(($pos = strpos($link,"&".$parametr."=",0)) !== false) { $delic = "&"; }
    if($delic != "") {
        if($test) { Write("<p style='display: none'>Vstup: ".$link."</p>"); }
        $dl2 = strlen($delic.$parametr."=");
        if(($pos = strpos($link,$delic.$parametr."=",0)) !== false) {
            if($ActionLinkPos === false || $ActionLinkPos > $pos) {
                if(($pos2 = strpos($link,"&",($pos+$dl2))) !== false) {
                    $dellength = $pos2 - $pos;
                    if($test) { Write("<p style='display: none'>Test 1a: ".$delic.$parametr."</p>"); }
                    if($test) { Write("<p style='display: none'>Test 1b: ".$dellength."</p>"); }
                    $search_param = substr($link,$pos,$dellength);
                    $NewLink = str_replace($search_param,"",$link);
                    if($test) { Write("<p style='display: none'>Test 1c: ".$NewLink."</p>"); }}
                else {
                    $dellength = $dl - $pos;
                    if($test) { Write("<p style='display: none'>Test 2a: ".$delic.$parametr."</p>"); }
                    if($test) { Write("<p style='display: none'>Test 2b: ".$dellength."</p>"); }
                    $NewLink = substr($link,0,$pos);
                    if($test) { Write("<p style='display: none'>Test 2c: ".$NewLink."</p>"); }}}}
        if($delic == "?") {
            if($test) { Write("<p style='display: none'>Test 1e: ".$NewLink."</p>"); }
            if(($pos = strpos($NewLink,"&",0)) !== false) {
                $NewLink1 = substr($NewLink,0,$pos);
                $NewLink1.= "?";
                $NewLink1.= substr($NewLink,$pos+1);
                $NewLink = $NewLink1;
                if($test) { Write("<p style='display: none'>Test 1d: ".$NewLink."</p>"); }}}}
    return $NewLink;}
function GetParam($link,$parametr,$test=false) {
    $dl = strlen($link);
    $Value = "";
    $ActionLinkPos = strpos($link,"ActionLink=",0);
    $delic = "";
    if(($pos = strpos($link,"?".$parametr."=",0)) !== false) { $delic = "?"; }
    if(($pos = strpos($link,"&".$parametr."=",0)) !== false) { $delic = "&"; }
    if($delic != "") {
        $dl2 = strlen($delic.$parametr."=");
        if(($pos = strpos($link,$delic.$parametr."=",0)) !== false) {
            if($ActionLinkPos === false || $ActionLinkPos > $pos) {
                if(($pos2 = strpos($link,"&",($pos+$dl2))) !== false) {
                    $dellength = $pos2 - $pos;
                    $Value = str_replace($delic.$parametr."=","",substr($link,$pos,$dellength));}
                else {
                    $dellength = $dl - $pos;
                    $Value = str_replace($delic.$parametr."=","",substr($link,$pos,$dellength));}}}}
    return $Value;}
function DeleteAllParams($link,$keep_sc=false,$keep_su=false,$keep_ac=false,$test=false) {
    $dl = strlen($link);
    $sc = GetParam($link,"sc");
    $su = GetParam($link,"su");
    $ac = GetParam($link,"ac");
    $NewLink = $link;
    $delic = "";
    if(($pos = strpos($link,"?",0)) !== false) { $delic = "?"; }
    else {
        if(($pos = strpos($link,"&",0)) !== false) { $delic = "&"; }}
    if($delic != "") {
        $NewLink = substr($link,0,($pos));}
    if($keep_sc) { $NewLink = AddParam($NewLink,'sc',$sc); }
    if($keep_su) { $NewLink = AddParam($NewLink,'su',$su); }
    if($keep_ac) { $NewLink = AddParam($NewLink,'ac',$ac); }
    return $NewLink;}
function TestLink($link) {
    $nasel = false;
    if(($pos = strpos(strtolower($link),".php")) !== false) { $nasel = true; }
    if(($pos = strpos(strtolower($link),".png")) !== false) { $nasel = true; }
    if(($pos = strpos(strtolower($link),".jpg")) !== false) { $nasel = true; }
    if(($pos = strpos(strtolower($link),".jpeg")) !== false) { $nasel = true; }
    if(($pos = strpos(strtolower($link),".gif")) !== false) { $nasel = true; }
    if(($pos = strpos(strtolower($link),".htm")) !== false) { $nasel = true; }
    if(($pos = strpos(strtolower($link),".html")) !== false) { $nasel = true; }
    if(($pos = strpos(strtolower($link),".exe")) !== false) { $nasel = true; }
    if(($pos = strpos(strtolower($link),".zip")) !== false) { $nasel = true; }
    if(($pos = strpos(strtolower($link),".rar")) !== false) { $nasel = true; }
    if(($pos = strpos(strtolower($link),".mp3")) !== false) { $nasel = true; }
    if(($pos = strpos(strtolower($link),"monotea.com")) === false) { $nasel = true; }
    if($nasel) { $link2 = ""; }
    else { $link2 = "/"; }
    return $link2;}
function LanguageLink($link,$language) {
    global $MTPS;
    $language = strtolower($language);
    if(($get_pos = strpos($link,"?")) !== false) {
        $get_part = substr($link,$get_pos);
        $link = substr($link,0,$get_pos);}
    else {
        $get_part = "";}
    if(($pos1 = strpos($link,"://")) !== false && $pos1 <= 5) { $pos1+= 3; } else { $pos1 = 0; }
    if(($pos2 = strpos($link,"/",$pos1)) === false) { $pos2 = -1; }
    if($pos2 > -1) {
        $path_part = substr($link,$pos2+1);
        $host_part = substr($link,0,$pos2+1);}
    else {
        $path_part = "";
        $host_part = $link."/";}
    $count = 0;
    $arr1 = array();
    $arr2 = explode('/',$path_part);
    foreach($arr2 as $key => $val) {
        if($val != "") {
            if(!IsLanguage($val)) {
                $arr1[$count] = $val;
                $count++;}}}
    $lang_part = "";
    if($MTPS->DefaultLanguageInLink || $language != $MTPS->DefaultLanguage) { $lang_part = $language."/"; }
    $link = $host_part.$lang_part;
    for($aa=0; $aa<$count; $aa++) { $link.= $arr1[$aa]; if($aa < $count-1) { $link.= "/"; } }
    $link.= $get_part;
    return $link;}
function TimestampFromDATE($isodate) {
    $date = explode("-",$isodate);
    return mktime(0,0,0,intval($date[1]),intval($date[2]),intval($date[0]));}
function TimestampFromDATETIME($isodatetime) {
    $both = explode(chr(32),$isodatetime);
    $date = explode("-",$both[0]);
    $time = explode(":",$both[1]);
    return mktime(intval($time[0]),intval($time[1]),0,intval($date[1]),intval($date[2]),intval($date[0]));}
function DateStringToDATE($str) {
    $str = str_replace(chr(32),"",$str);
    $arr = explode(".",$str);
    $date = sprintf("%04d-%02d-%02d",$arr[2],$arr[1],$arr[0]);
    return $date;}
function TimeStringToTIME($str) {
    $str = str_replace(chr(32),"",$str);
    $arr = explode(":",$str);
    if(!IsSet($arr[2])) { $arr[2] = "00"; }
    $time = sprintf("%02d:%02d:%02d",$arr[0],$arr[1],$arr[2]);
    return $time;}
function DateAndTimeFromDATEAndTIME_ForNews($iso_date,$iso_time) {
    $date = explode("-",$iso_date);
    $time = explode(":",$iso_time);
    if($date[0] == Date("Y")) {
        if($date[1] == Date("m") && $date[2] == Date("d")) {
            $str = sprintf("%s, %02d:%02d",Lng('Today'),$time[0],$time[1]);}
        else {
            $str = sprintf("%d. %s, %02d:%02d",$date[2],GetMonthName2($date[1]),$time[0],$time[1]);}}
    else {
        $str = sprintf("%d. %s %04d, %02d:%02d",$date[2],GetMonthName2($date[1]),$date[0],$time[0],$time[1]);}
    return $str;}
function DateFromDATE_ForNews($iso_date) {
    $date = explode("-",$iso_date);
    if($date[0] == Date("Y")) {
        if($date[1] == Date("m") && $date[2] == Date("d")) {
            $str = sprintf("%s",Lng('Today'));}
        else {
            $str = sprintf("%02d. %02d",$date[2],$date[1]);}}
    else {
        $str = sprintf("%02d. %02d %04d",$date[2],$date[1],$date[0]);}
    return $str;}
function DateAndTimeFromDATETIME($datetime) {
    $both = explode(chr(32),$datetime);
    $date = explode("-",$both[0]);
    $time = explode(":",$both[1]);
    return sprintf("%d. %d. %04d, %02d:%02d",$date[2],$date[1],$date[0],$time[0],$time[1]);}
function DateFromDATE($isodate) {
    if($isodate == "0000-00-00") { return "N/A"; }
    $date = explode("-",$isodate);
    return sprintf("%d. %d. %04d",$date[2],$date[1],$date[0]);}
function TimeFromTIME($datetime) {
    $time = explode(":",$datetime);
    return sprintf("%02d:%02d",$time[0],$time[1]);}
function TimeToDATETIME($timestamp="") {
    if($timestamp == "") { $timestamp = Time(); }
    return Date("Y-m-d H:i:s",$timestamp);}
function TimeToDATE($timestamp="") {
    if($timestamp == "") { $timestamp = Time(); }
    return Date("Y-m-d",$timestamp);}
function TimeToTIME($timestamp="") {
    if($timestamp == "") { $timestamp = Time(); }
    return Date("H:i:s",$timestamp);}
function TimeToISODate($timestamp="") {
    if($timestamp == "") { $timestamp = Time(); }
    return Date("Y-m-d",$timestamp);}
function DateStr($stamp=-1,$write_today=false,$write_yesterday=false,$write_tomorrow=false,$write_year=true) {
    if($stamp == -1) { $stamp = Time(); }
    if($write_today && $stamp >= $GLOBALS['TodayStarts'] && $stamp <= $GLOBALS['TodayEnds']) { return Lng('Today'); }
    if($write_yesterday && $stamp >= $GLOBALS['TodayStarts']-24*60*60 && $stamp < $GLOBALS['TodayStarts']) { return Lng('Yesterday'); }
    if($write_tomorrow && $stamp >= $GLOBALS['TodayStarts']+24*60*60 && $stamp < $GLOBALS['TodayStarts']+2*24*60*60) { return Lng('Tomorrow'); }
    if(!$write_year) { return Date("j.n.",$stamp); }
    return Date("j.n.Y",$stamp);}
function NiceDateStr($stamp=-1,$write_today=false,$write_yesterday=false,$write_tomorrow=false,$write_year=true) {
    if($stamp == -1) { $stamp = Time(); }
    if($write_today && $stamp >= $GLOBALS['TodayStarts'] && $stamp <= $GLOBALS['TodayEnds']) { return Lng('Today'); }
    if($write_yesterday && $stamp >= $GLOBALS['TodayStarts']-24*60*60 && $stamp < $GLOBALS['TodayStarts']) { return Lng('Yesterday'); }
    if($write_tomorrow && $stamp >= $GLOBALS['TodayStarts']+24*60*60 && $stamp < $GLOBALS['TodayStarts']+2*24*60*60) { return Lng('Tomorrow'); }
    if(!$write_year) {
        return Date("j.",$stamp).chr(32).GetMonthName2(Date("n",$stamp));}
    return Date("j.",$stamp).chr(32).GetMonthName2(Date("n",$stamp)).chr(32).Date("Y",$stamp);}
function TimeStr($stamp="",$seconds=true) {
    if($stamp == "") { $stamp = Time(); }
    if($seconds) { return Date("H:i:s",$stamp); }
    else { return Date("H:i",$stamp); }}
function GetDayNameFromStr($day) {
    switch(strtolower($day)) {
        case "mon": return Lng('Monday');
        case "tue": return Lng('Tuesday');
        case "wed": return Lng('Wednesday');
        case "thu": return Lng('Thursday');
        case "fri": return Lng('Friday');
        case "sat": return Lng('Saturday');
        case "sun": return Lng('Sunday');}
    return $day;}
function GetShortDayNameFromStr($day) {
    switch(strtolower($day)) {
        case "mon": return Lng('Mon');
        case "tue": return Lng('Tue');
        case "wed": return Lng('Wed');
        case "thu": return Lng('Thu');
        case "fri": return Lng('Fri');
        case "sat": return Lng('Sat');
        case "sun": return Lng('Sun');}
    return $day;}
function GetMonthName($month) {
    switch($month) {
        case 1: return Lng('January');
        case 2: return Lng('February');
        case 3: return Lng('March');
        case 4: return Lng('April');
        case 5: return Lng('May');
        case 6: return Lng('June');
        case 7: return Lng('July');
        case 8: return Lng('August');
        case 9: return Lng('September');
        case 10: return Lng('October');
        case 11: return Lng('November');
        case 12: return Lng('December');}
    return $month;}
function GetMonthName2($month) {
    switch($month) {
        case 1: return Lng('OfJanuary');
        case 2: return Lng('OfFebruary');
        case 3: return Lng('OfMarch');
        case 4: return Lng('OfApril');
        case 5: return Lng('OfMay');
        case 6: return Lng('OfJune');
        case 7: return Lng('OfJuly');
        case 8: return Lng('OfAugust');
        case 9: return Lng('OfSeptember');
        case 10: return Lng('OfOctober');
        case 11: return Lng('OfNovember');
        case 12: return Lng('OfDecember');}
    return $month;}
function SetNameOfDay(&$arr,&$count,$month,$date,$type,$name) {
    $arr[$count] = new stdClass();
    $arr[$count]->Month = $month;
    $arr[$count]->Date = $date;
    $arr[$count]->Type = $type;
    $arr[$count]->Name = $name;
    $count++;
    return $arr;}
function CreateNamesOfDayArray() {
    $names = array();
    $count = 0;
    $names['MonthBegin1'] = $count;
    SetNameOfDay($names,$count, 1, 1,1,"Mečislav");
    SetNameOfDay($names,$count, 1, 1,2,"Mečislava");
    SetNameOfDay($names,$count, 1, 1,5,"Nový rok");
    SetNameOfDay($names,$count, 1, 1,5,"Den obnovy samostatného českého státu");
    SetNameOfDay($names,$count, 1, 2,2,"Karina");
    SetNameOfDay($names,$count, 1, 2,1,"Vasil");
    SetNameOfDay($names,$count, 1, 3,2,"Radmila");
    SetNameOfDay($names,$count, 1, 3,1,"Radomil");
    SetNameOfDay($names,$count, 1, 4,2,"Diana");
    SetNameOfDay($names,$count, 1, 4,2,"Dajana");
    SetNameOfDay($names,$count, 1, 5,2,"Dalimil");
    SetNameOfDay($names,$count, 1, 5,2,"Dalimila");
    SetNameOfDay($names,$count, 1, 6,1,"Kašpar");
    SetNameOfDay($names,$count, 1, 6,1,"Melichar");
    SetNameOfDay($names,$count, 1, 6,1,"Baltazar");
    SetNameOfDay($names,$count, 1, 6,7,"Tři králové");
    SetNameOfDay($names,$count, 1, 7,2,"Vilma");
    SetNameOfDay($names,$count, 1, 7,2,"Vilemína");
    SetNameOfDay($names,$count, 1, 8,1,"Čestmír");
    SetNameOfDay($names,$count, 1, 8,1,"Erhard");
    SetNameOfDay($names,$count, 1, 9,1,"Vladan");
    SetNameOfDay($names,$count, 1, 9,2,"Vladana");
    SetNameOfDay($names,$count, 1,10,1,"Břetislav");
    SetNameOfDay($names,$count, 1,10,2,"Břetislava");
    SetNameOfDay($names,$count, 1,11,2,"Bohdana");
    SetNameOfDay($names,$count, 1,11,2,"Teodora");
    SetNameOfDay($names,$count, 1,12,1,"Pravoslav");
    SetNameOfDay($names,$count, 1,12,2,"Pravoslava");
    SetNameOfDay($names,$count, 1,13,2,"Edita");
    SetNameOfDay($names,$count, 1,13,2,"Leontýna");
    SetNameOfDay($names,$count, 1,14,1,"Radovan");
    SetNameOfDay($names,$count, 1,14,2,"Radovana");
    SetNameOfDay($names,$count, 1,15,2,"Alice");
    SetNameOfDay($names,$count, 1,15,2,"Alison");
    SetNameOfDay($names,$count, 1,16,1,"Ctirad");
    SetNameOfDay($names,$count, 1,16,1,"Ctislav");
    SetNameOfDay($names,$count, 1,16,7,"Den památky Jana Palacha");
    SetNameOfDay($names,$count, 1,17,1,"Drahoslav");
    SetNameOfDay($names,$count, 1,17,1,"Drahoš");
    SetNameOfDay($names,$count, 1,18,1,"Vladislav");
    SetNameOfDay($names,$count, 1,18,2,"Vladislava");
    SetNameOfDay($names,$count, 1,19,1,"Doubravka");
    SetNameOfDay($names,$count, 1,19,2,"Fabián");
    SetNameOfDay($names,$count, 1,20,2,"Ilona");
    SetNameOfDay($names,$count, 1,20,1,"Sebastián");
    SetNameOfDay($names,$count, 1,21,2,"Běla");
    SetNameOfDay($names,$count, 1,21,2,"Bianka");
    SetNameOfDay($names,$count, 1,22,1,"Slavomír");
    SetNameOfDay($names,$count, 1,22,1,"Slávek");
    SetNameOfDay($names,$count, 1,23,1,"Zdeněk");
    SetNameOfDay($names,$count, 1,23,1,"Raimund");
    SetNameOfDay($names,$count, 1,24,2,"Milena");
    SetNameOfDay($names,$count, 1,24,1,"Timotej");
    SetNameOfDay($names,$count, 1,25,1,"Miloš");
    SetNameOfDay($names,$count, 1,25,1,"Miloň");
    SetNameOfDay($names,$count, 1,26,2,"Zora");
    SetNameOfDay($names,$count, 1,26,1,"Zoran");
    SetNameOfDay($names,$count, 1,27,2,"Ingrid");
    SetNameOfDay($names,$count, 1,27,2,"Ingeborg");
    SetNameOfDay($names,$count, 1,27,7,"Den památky obětí holocaustu a předcházení zločinům proti lidskosti");
    SetNameOfDay($names,$count, 1,28,2,"Otýlie");
    SetNameOfDay($names,$count, 1,28,1,"Manfréd");
    SetNameOfDay($names,$count, 1,29,2,"Zdislava");
    SetNameOfDay($names,$count, 1,29,1,"Zdislav");
    SetNameOfDay($names,$count, 1,30,1,"Robin");
    SetNameOfDay($names,$count, 1,30,2,"Erna");
    SetNameOfDay($names,$count, 1,31,2,"Marika");
    SetNameOfDay($names,$count, 1,31,2,"Marieta");
    $names['MonthBegin2'] = $count;
    SetNameOfDay($names,$count, 2, 1,1,"Hynek");
    SetNameOfDay($names,$count, 2, 1,2,"Jasmína");
    SetNameOfDay($names,$count, 2, 2,2,"Nela");
    SetNameOfDay($names,$count, 2, 2,2,"Aida");
    SetNameOfDay($names,$count, 2, 3,1,"Blažej");
    SetNameOfDay($names,$count, 2, 3,1,"Donald");
    SetNameOfDay($names,$count, 2, 4,2,"Jarmila");
    SetNameOfDay($names,$count, 2, 4,1,"Gilbert");
    SetNameOfDay($names,$count, 2, 5,2,"Dobromila");
    SetNameOfDay($names,$count, 2, 5,1,"Dobromil");
    SetNameOfDay($names,$count, 2, 6,2,"Vanda");
    SetNameOfDay($names,$count, 2, 6,2,"Samanta");
    SetNameOfDay($names,$count, 2, 7,2,"Veronika");
    SetNameOfDay($names,$count, 2, 7,2,"Berenika");
    SetNameOfDay($names,$count, 2, 8,2,"Milada");
    SetNameOfDay($names,$count, 2, 8,2,"Aranka");
    SetNameOfDay($names,$count, 2, 9,2,"Apolena");
    SetNameOfDay($names,$count, 2, 9,1,"Ronald");
    SetNameOfDay($names,$count, 2,10,1,"Mojmír");
    SetNameOfDay($names,$count, 2,10,2,"Mojmíra");
    SetNameOfDay($names,$count, 2,11,2,"Božena");
    SetNameOfDay($names,$count, 2,11,1,"Dezier");
    SetNameOfDay($names,$count, 2,12,2,"Slavěna");
    SetNameOfDay($names,$count, 2,12,2,"Slávka");
    SetNameOfDay($names,$count, 2,13,1,"Věnceslav");
    SetNameOfDay($names,$count, 2,13,2,"Věnceslava");
    SetNameOfDay($names,$count, 2,14,1,"Valentýn");
    SetNameOfDay($names,$count, 2,14,2,"Valentýna");
    SetNameOfDay($names,$count, 2,15,2,"Jiřina");
    SetNameOfDay($names,$count, 2,15,2,"Jorga");
    SetNameOfDay($names,$count, 2,16,2,"Ljuba");
    SetNameOfDay($names,$count, 2,16,2,"Danuta");
    SetNameOfDay($names,$count, 2,17,2,"Miloslava");
    SetNameOfDay($names,$count, 2,17,2,"Fiona");
    SetNameOfDay($names,$count, 2,18,2,"Gizela");
    SetNameOfDay($names,$count, 2,18,2,"Favie");
    SetNameOfDay($names,$count, 2,19,1,"Patrik");
    SetNameOfDay($names,$count, 2,19,1,"Mansvet");
    SetNameOfDay($names,$count, 2,20,1,"Oldřich");
    SetNameOfDay($names,$count, 2,20,1,"Dorián");
    SetNameOfDay($names,$count, 2,21,2,"Lenka");
    SetNameOfDay($names,$count, 2,21,2,"Eleonora");
    SetNameOfDay($names,$count, 2,22,1,"Petr");
    SetNameOfDay($names,$count, 2,22,2,"Etela");
    SetNameOfDay($names,$count, 2,23,1,"Svatopluk");
    SetNameOfDay($names,$count, 2,23,1,"Svatobor");
    SetNameOfDay($names,$count, 2,24,1,"Matěj");
    SetNameOfDay($names,$count, 2,24,1,"Matyáš");
    SetNameOfDay($names,$count, 2,25,2,"Liliana");
    SetNameOfDay($names,$count, 2,25,1,"Taras");
    SetNameOfDay($names,$count, 2,26,2,"Dorota");
    SetNameOfDay($names,$count, 2,26,2,"Doris");
    SetNameOfDay($names,$count, 2,27,1,"Alexandr");
    SetNameOfDay($names,$count, 2,27,1,"Saša");
    SetNameOfDay($names,$count, 2,28,1,"Lumír");
    SetNameOfDay($names,$count, 2,28,2,"Kira");
    SetNameOfDay($names,$count, 2,29,1,"Horymír");
    $names['MonthBegin3'] = $count;
    SetNameOfDay($names,$count, 3, 1,1,"Bedřich");
    SetNameOfDay($names,$count, 3, 1,2,"Bedřiška");
    SetNameOfDay($names,$count, 3, 2,2,"Anežka");
    SetNameOfDay($names,$count, 3, 2,2,"Inéz");
    SetNameOfDay($names,$count, 3, 3,1,"Kamil");
    SetNameOfDay($names,$count, 3, 3,1,"Vladivoj");
    SetNameOfDay($names,$count, 3, 4,2,"Stela");
    SetNameOfDay($names,$count, 3, 4,2,"Jadranka");
    SetNameOfDay($names,$count, 3, 5,1,"Kazimír");
    SetNameOfDay($names,$count, 3, 5,2,"Kazimíra");
    SetNameOfDay($names,$count, 3, 6,1,"Miroslav");
    SetNameOfDay($names,$count, 3, 6,1,"Mirek");
    SetNameOfDay($names,$count, 3, 7,1,"Tomáš");
    SetNameOfDay($names,$count, 3, 7,1,"Tom");
    SetNameOfDay($names,$count, 3, 8,2,"Gabriela");
    SetNameOfDay($names,$count, 3, 8,1,"Zoltán");
    SetNameOfDay($names,$count, 3, 8,7,"Mezinárodní den žen");
    SetNameOfDay($names,$count, 3, 9,2,"Františka");
    SetNameOfDay($names,$count, 3, 9,2,"Rebeka");
    SetNameOfDay($names,$count, 3,10,2,"Viktorie");
    SetNameOfDay($names,$count, 3,10,2,"Melita");
    SetNameOfDay($names,$count, 3,11,2,"Anděla");
    SetNameOfDay($names,$count, 3,11,2,"Angelika");
    SetNameOfDay($names,$count, 3,12,1,"Řehoř");
    SetNameOfDay($names,$count, 3,12,1,"Křesomysl");
    SetNameOfDay($names,$count, 3,12,7,"Den přístupu České republiky k Severoatlantické smlouvě (NATO)");
    SetNameOfDay($names,$count, 3,13,2,"Růžena");
    SetNameOfDay($names,$count, 3,13,2,"Róza");
    SetNameOfDay($names,$count, 3,14,2,"Rút");
    SetNameOfDay($names,$count, 3,14,2,"Matylda");
    SetNameOfDay($names,$count, 3,15,2,"Ida");
    SetNameOfDay($names,$count, 3,15,2,"Hilda");
    SetNameOfDay($names,$count, 3,16,2,"Elena");
    SetNameOfDay($names,$count, 3,16,2,"Ella");
    SetNameOfDay($names,$count, 3,17,1,"Vlastimil");
    SetNameOfDay($names,$count, 3,17,2,"Vlastimila");
    SetNameOfDay($names,$count, 3,18,1,"Eduard");
    SetNameOfDay($names,$count, 3,18,2,"Eduarda");
    SetNameOfDay($names,$count, 3,19,1,"Josef");
    SetNameOfDay($names,$count, 3,19,2,"Josefa");
    SetNameOfDay($names,$count, 3,20,2,"Světlana");
    SetNameOfDay($names,$count, 3,20,2,"Světla");
    SetNameOfDay($names,$count, 3,21,1,"Radek");
    SetNameOfDay($names,$count, 3,21,1,"Radko");
    SetNameOfDay($names,$count, 3,22,2,"Leona");
    SetNameOfDay($names,$count, 3,22,2,"Lea");
    SetNameOfDay($names,$count, 3,23,2,"Ivona");
    SetNameOfDay($names,$count, 3,23,1,"Alfons");
    SetNameOfDay($names,$count, 3,24,1,"Gabriel");
    SetNameOfDay($names,$count, 3,24,1,"Zbyslav");
    SetNameOfDay($names,$count, 3,25,1,"Marián");
    SetNameOfDay($names,$count, 3,25,1,"Mario");
    SetNameOfDay($names,$count, 3,26,1,"Emanuel");
    SetNameOfDay($names,$count, 3,26,2,"Emanuela");
    SetNameOfDay($names,$count, 3,27,2,"Dita");
    SetNameOfDay($names,$count, 3,27,2,"Malvína");
    SetNameOfDay($names,$count, 3,28,2,"Soňa");
    SetNameOfDay($names,$count, 3,28,1,"Gedeon");
    SetNameOfDay($names,$count, 3,29,2,"Taťána");
    SetNameOfDay($names,$count, 3,29,1,"Slavomil");
    SetNameOfDay($names,$count, 3,30,1,"Arnošt");
    SetNameOfDay($names,$count, 3,30,1,"Ernest");
    SetNameOfDay($names,$count, 3,31,1,"Kvido");
    SetNameOfDay($names,$count, 3,31,1,"Arpád");
    $names['MonthBegin4'] = $count;
    SetNameOfDay($names,$count, 4, 1,1,"Hugo");
    SetNameOfDay($names,$count, 4, 1,1,"Veleslav");
    SetNameOfDay($names,$count, 4, 2,2,"Erika");
    SetNameOfDay($names,$count, 4, 2,1,"Áron");
    SetNameOfDay($names,$count, 4, 3,1,"Richard");
    SetNameOfDay($names,$count, 4, 3,2,"Richarda");
    SetNameOfDay($names,$count, 4, 4,2,"Ivana");
    SetNameOfDay($names,$count, 4, 4,1,"Izidor");
    SetNameOfDay($names,$count, 4, 5,2,"Miroslava");
    SetNameOfDay($names,$count, 4, 5,2,"Mirka");
    SetNameOfDay($names,$count, 4, 6,2,"Vendula");
    SetNameOfDay($names,$count, 4, 6,2,"Venuše");
    SetNameOfDay($names,$count, 4, 7,1,"Heřman");
    SetNameOfDay($names,$count, 4, 7,2,"Hermína");
    SetNameOfDay($names,$count, 4, 7,7,"Den vzdělanosti");
    SetNameOfDay($names,$count, 4, 8,2,"Ema");
    SetNameOfDay($names,$count, 4, 8,2,"Konstantýna");
    SetNameOfDay($names,$count, 4, 9,1,"Dušan");
    SetNameOfDay($names,$count, 4, 9,2,"Dušana");
    SetNameOfDay($names,$count, 4,10,2,"Darja");
    SetNameOfDay($names,$count, 4,10,2,"Darie");
    SetNameOfDay($names,$count, 4,11,2,"Izabela");
    SetNameOfDay($names,$count, 4,11,2,"Ariel");
    SetNameOfDay($names,$count, 4,12,1,"Julius");
    SetNameOfDay($names,$count, 4,12,1,"Julián");
    SetNameOfDay($names,$count, 4,13,1,"Aleš");
    SetNameOfDay($names,$count, 4,13,2,"Norma");
    SetNameOfDay($names,$count, 4,14,1,"Vincenc");
    SetNameOfDay($names,$count, 4,14,1,"Vincent");
    SetNameOfDay($names,$count, 4,15,2,"Anastázie");
    SetNameOfDay($names,$count, 4,15,1,"Oktavián");
    SetNameOfDay($names,$count, 4,16,2,"Irena");
    SetNameOfDay($names,$count, 4,16,1,"Ireneus");
    SetNameOfDay($names,$count, 4,17,1,"Rudolf");
    SetNameOfDay($names,$count, 4,17,2,"Rudolfa");
    SetNameOfDay($names,$count, 4,18,2,"Valérie");
    SetNameOfDay($names,$count, 4,18,1,"Varner");
    SetNameOfDay($names,$count, 4,19,1,"Rostislav");
    SetNameOfDay($names,$count, 4,19,2,"Rostislava");
    SetNameOfDay($names,$count, 4,20,2,"Marcela");
    SetNameOfDay($names,$count, 4,20,2,"Odeta");
    SetNameOfDay($names,$count, 4,21,2,"Alexandra");
    SetNameOfDay($names,$count, 4,21,2,"Selma");
    SetNameOfDay($names,$count, 4,22,2,"Evženie");
    SetNameOfDay($names,$count, 4,22,1,"Leonid");
    SetNameOfDay($names,$count, 4,23,1,"Vojtěch");
    SetNameOfDay($names,$count, 4,23,1,"Gerhard");
    SetNameOfDay($names,$count, 4,24,1,"Jiří");
    SetNameOfDay($names,$count, 4,24,1,"Fidel");
    SetNameOfDay($names,$count, 4,25,1,"Marek");
    SetNameOfDay($names,$count, 4,25,1,"Ervin");
    SetNameOfDay($names,$count, 4,26,1,"Oto");
    SetNameOfDay($names,$count, 4,26,1,"Ota");
    SetNameOfDay($names,$count, 4,27,1,"Jaroslav");
    SetNameOfDay($names,$count, 4,27,1,"Jarolím");
    SetNameOfDay($names,$count, 4,28,1,"Vlastislav");
    SetNameOfDay($names,$count, 4,28,2,"Vlastislava");
    SetNameOfDay($names,$count, 4,29,1,"Robert");
    SetNameOfDay($names,$count, 4,29,2,"Roberta");
    SetNameOfDay($names,$count, 4,30,1,"Blahoslav");
    SetNameOfDay($names,$count, 4,30,2,"Blahoslava");
    $names['MonthBegin5'] = $count;
    SetNameOfDay($names,$count, 5, 1,2,"Pamela");
    SetNameOfDay($names,$count, 5, 1,1,"Jeremiáš");
    SetNameOfDay($names,$count, 5, 1,5,"Svátek práce");
    SetNameOfDay($names,$count, 5, 2,1,"Zikmund");
    SetNameOfDay($names,$count, 5, 2,1,"Atanas");
    SetNameOfDay($names,$count, 5, 3,1,"Alexej");
    SetNameOfDay($names,$count, 5, 3,2,"Alexa");
    SetNameOfDay($names,$count, 5, 4,1,"Květoslav");
    SetNameOfDay($names,$count, 5, 4,1,"Florián");
    SetNameOfDay($names,$count, 5, 5,2,"Klaudie");
    SetNameOfDay($names,$count, 5, 5,1,"Klaudius");
    SetNameOfDay($names,$count, 5, 6,1,"Radoslav");
    SetNameOfDay($names,$count, 5, 6,1,"Radislav");
    SetNameOfDay($names,$count, 5, 7,1,"Stanislav");
    SetNameOfDay($names,$count, 5, 7,2,"Dalma");
    SetNameOfDay($names,$count, 5, 8,1,"Zlatan");
    SetNameOfDay($names,$count, 5, 8,1,"Zlatomír");
    SetNameOfDay($names,$count, 5, 8,5,"Den vítězství");
    SetNameOfDay($names,$count, 5, 9,1,"Ctibor");
    SetNameOfDay($names,$count, 5, 9,2,"Ctibora");
    SetNameOfDay($names,$count, 5,10,2,"Blažena");
    SetNameOfDay($names,$count, 5,10,1,"Gordon");
    SetNameOfDay($names,$count, 5,11,2,"Svatava");
    SetNameOfDay($names,$count, 5,11,2,"Svatoslava");
    SetNameOfDay($names,$count, 5,12,1,"Pankrác");
    SetNameOfDay($names,$count, 5,12,1,"Vsevolod");
    SetNameOfDay($names,$count, 5,13,1,"Servác");
    SetNameOfDay($names,$count, 5,13,2,"Ofélie");
    SetNameOfDay($names,$count, 5,14,1,"Bonifác");
    SetNameOfDay($names,$count, 5,14,2,"Dina");
    SetNameOfDay($names,$count, 5,15,2,"Žofie");
    SetNameOfDay($names,$count, 5,15,2,"Sofie");
    SetNameOfDay($names,$count, 5,15,7,"Den rodin");
    SetNameOfDay($names,$count, 5,16,1,"Přemysl");
    SetNameOfDay($names,$count, 5,16,1,"Přemek");
    SetNameOfDay($names,$count, 5,17,2,"Aneta");
    SetNameOfDay($names,$count, 5,17,1,"Paskal");
    SetNameOfDay($names,$count, 5,18,2,"Nataša");
    SetNameOfDay($names,$count, 5,18,2,"Timea");
    SetNameOfDay($names,$count, 5,19,1,"Ivo");
    SetNameOfDay($names,$count, 5,19,1,"Celestýn");
    SetNameOfDay($names,$count, 5,20,1,"Zbyšek");
    SetNameOfDay($names,$count, 5,20,2,"Zbyška");
    SetNameOfDay($names,$count, 5,21,2,"Monika");
    SetNameOfDay($names,$count, 5,21,2,"Mona");
    SetNameOfDay($names,$count, 5,22,1,"Emil");
    SetNameOfDay($names,$count, 5,22,2,"Rita");
    SetNameOfDay($names,$count, 5,23,1,"Vladimír");
    SetNameOfDay($names,$count, 5,23,2,"Vladimíra");
    SetNameOfDay($names,$count, 5,24,2,"Jana");
    SetNameOfDay($names,$count, 5,24,2,"Vanesa");
    SetNameOfDay($names,$count, 5,25,2,"Viola");
    SetNameOfDay($names,$count, 5,25,2,"Violeta");
    SetNameOfDay($names,$count, 5,26,1,"Filip");
    SetNameOfDay($names,$count, 5,26,2,"Filipa");
    SetNameOfDay($names,$count, 5,27,1,"Valdemar");
    SetNameOfDay($names,$count, 5,27,1,"Vadim");
    SetNameOfDay($names,$count, 5,28,1,"Vilém");
    SetNameOfDay($names,$count, 5,28,1,"Vilibald");
    SetNameOfDay($names,$count, 5,29,1,"Maxmilián");
    SetNameOfDay($names,$count, 5,29,1,"Maxim");
    SetNameOfDay($names,$count, 5,30,1,"Ferdinand");
    SetNameOfDay($names,$count, 5,30,2,"Ferdinanda");
    SetNameOfDay($names,$count, 5,31,2,"Kamila");
    SetNameOfDay($names,$count, 5,31,2,"Petronela");
    $names['MonthBegin6'] = $count;
    SetNameOfDay($names,$count, 6, 1,2,"Laura");
    SetNameOfDay($names,$count, 6, 1,2,"Lora");
    SetNameOfDay($names,$count, 6, 1,7,"Mezinárodní den dětí");
    SetNameOfDay($names,$count, 6, 2,1,"Jarmil");
    SetNameOfDay($names,$count, 6, 2,1,"Jaromil");
    SetNameOfDay($names,$count, 6, 3,2,"Tamara");
    SetNameOfDay($names,$count, 6, 3,1,"Kevin");
    SetNameOfDay($names,$count, 6, 4,1,"Dalibor");
    SetNameOfDay($names,$count, 6, 4,2,"Dalibora");
    SetNameOfDay($names,$count, 6, 5,1,"Dobroslav");
    SetNameOfDay($names,$count, 6, 5,2,"Dobroslava");
    SetNameOfDay($names,$count, 6, 6,1,"Norbert");
    SetNameOfDay($names,$count, 6, 6,1,"Norman");
    SetNameOfDay($names,$count, 6, 7,2,"Iveta");
    SetNameOfDay($names,$count, 6, 7,1,"Slavoj");
    SetNameOfDay($names,$count, 6, 8,1,"Medard");
    SetNameOfDay($names,$count, 6, 8,2,"Pěva");
    SetNameOfDay($names,$count, 6, 9,2,"Stanislava");
    SetNameOfDay($names,$count, 6, 9,2,"Anabela");
    SetNameOfDay($names,$count, 6,10,2,"Gita");
    SetNameOfDay($names,$count, 6,10,2,"Margita");
    SetNameOfDay($names,$count, 6,10,7,"Vyhlazení obce Lidice");
    SetNameOfDay($names,$count, 6,11,1,"Bruno");
    SetNameOfDay($names,$count, 6,11,1,"Barnabáš");
    SetNameOfDay($names,$count, 6,12,2,"Antonie");
    SetNameOfDay($names,$count, 6,12,2,"Táňa");
    SetNameOfDay($names,$count, 6,13,1,"Antonín");
    SetNameOfDay($names,$count, 6,13,1,"Tobiáš");
    SetNameOfDay($names,$count, 6,14,1,"Roland");
    SetNameOfDay($names,$count, 6,14,2,"Herta");
    SetNameOfDay($names,$count, 6,15,1,"Vít");
    SetNameOfDay($names,$count, 6,15,2,"Vita");
    SetNameOfDay($names,$count, 6,16,1,"Zbyněk");
    SetNameOfDay($names,$count, 6,16,1,"Zbyhněv");
    SetNameOfDay($names,$count, 6,17,1,"Adolf");
    SetNameOfDay($names,$count, 6,17,2,"Adina");
    SetNameOfDay($names,$count, 6,18,1,"Milan");
    SetNameOfDay($names,$count, 6,18,1,"Milana");
    SetNameOfDay($names,$count, 6,19,1,"Leoš");
    SetNameOfDay($names,$count, 6,19,1,"Leo");
    SetNameOfDay($names,$count, 6,20,2,"Květa");
    SetNameOfDay($names,$count, 6,20,2,"Květuše");
    SetNameOfDay($names,$count, 6,21,1,"Alois");
    SetNameOfDay($names,$count, 6,21,2,"Aloisie");
    SetNameOfDay($names,$count, 6,22,2,"Pavla");
    SetNameOfDay($names,$count, 6,22,2,"Zaira");
    SetNameOfDay($names,$count, 6,23,2,"Zdeňka");
    SetNameOfDay($names,$count, 6,23,2,"Zdenka");
    SetNameOfDay($names,$count, 6,24,1,"Jan");
    SetNameOfDay($names,$count, 6,24,1,"Jonatan");
    SetNameOfDay($names,$count, 6,25,1,"Ivan");
    SetNameOfDay($names,$count, 6,25,1,"Salome");
    SetNameOfDay($names,$count, 6,26,2,"Adriána");
    SetNameOfDay($names,$count, 6,26,1,"Adrian");
    SetNameOfDay($names,$count, 6,27,1,"Ladislav");
    SetNameOfDay($names,$count, 6,27,2,"Ladislava");
    SetNameOfDay($names,$count, 6,27,7,"Den památky obětí komunistického režimu");
    SetNameOfDay($names,$count, 6,28,1,"Lubomír");
    SetNameOfDay($names,$count, 6,28,2,"Lubomíra");
    SetNameOfDay($names,$count, 6,29,1,"Petr a Pavel");
    SetNameOfDay($names,$count, 6,30,2,"Šárka");
    SetNameOfDay($names,$count, 6,30,1,"Vlastimír");
    $names['MonthBegin7'] = $count;
    SetNameOfDay($names,$count, 7, 1,2,"Jaroslava");
    SetNameOfDay($names,$count, 7, 1,2,"Vesna");
    SetNameOfDay($names,$count, 7, 2,2,"Patricie");
    SetNameOfDay($names,$count, 7, 2,2,"Alma");
    SetNameOfDay($names,$count, 7, 3,1,"Radomír");
    SetNameOfDay($names,$count, 7, 3,2,"Radomíra");
    SetNameOfDay($names,$count, 7, 4,1,"Prokop");
    SetNameOfDay($names,$count, 7, 4,1,"Ulrich");
    SetNameOfDay($names,$count, 7, 5,1,"Cyril a Metoděj");
    SetNameOfDay($names,$count, 7, 5,5,"Den slovanských věrozvěstů Cyrila a Metoděje");
    SetNameOfDay($names,$count, 7, 6,1,"Spytihněv");
    SetNameOfDay($names,$count, 7, 6,1,"Izaiáš");
    SetNameOfDay($names,$count, 7, 6,5,"Den upálení mistra Jana Husa");
    SetNameOfDay($names,$count, 7, 7,2,"Bohuslava");
    SetNameOfDay($names,$count, 7, 7,2,"Donalda");
    SetNameOfDay($names,$count, 7, 8,2,"Nora");
    SetNameOfDay($names,$count, 7, 8,1,"Edgar");
    SetNameOfDay($names,$count, 7, 9,2,"Drahoslava");
    SetNameOfDay($names,$count, 7, 9,2,"Drahuše");
    SetNameOfDay($names,$count, 7,10,2,"Libuše");
    SetNameOfDay($names,$count, 7,10,2,"Amálie");
    SetNameOfDay($names,$count, 7,11,2,"Olga");
    SetNameOfDay($names,$count, 7,11,2,"Helga");
    SetNameOfDay($names,$count, 7,12,1,"Bořek");
    SetNameOfDay($names,$count, 7,12,1,"Bořislav");
    SetNameOfDay($names,$count, 7,13,2,"Markéta");
    SetNameOfDay($names,$count, 7,13,2,"Margarita");
    SetNameOfDay($names,$count, 7,14,2,"Karolína");
    SetNameOfDay($names,$count, 7,14,2,"Larisa");
    SetNameOfDay($names,$count, 7,15,1,"Jindřich");
    SetNameOfDay($names,$count, 7,15,1,"Egon");
    SetNameOfDay($names,$count, 7,16,1,"Luboš");
    SetNameOfDay($names,$count, 7,16,1,"Cedrik");
    SetNameOfDay($names,$count, 7,17,2,"Martina");
    SetNameOfDay($names,$count, 7,17,2,"Alreta");
    SetNameOfDay($names,$count, 7,18,2,"Drahomíra");
    SetNameOfDay($names,$count, 7,18,1,"Drahomír");
    SetNameOfDay($names,$count, 7,19,1,"Čeněk");
    SetNameOfDay($names,$count, 7,19,1,"Čeňka");
    SetNameOfDay($names,$count, 7,20,2,"Ilja");
    SetNameOfDay($names,$count, 7,20,1,"Eliáš");
    SetNameOfDay($names,$count, 7,21,1,"Vítězslav");
    SetNameOfDay($names,$count, 7,21,2,"Vítězslava");
    SetNameOfDay($names,$count, 7,22,2,"Magdaléna");
    SetNameOfDay($names,$count, 7,22,2,"Magda");
    SetNameOfDay($names,$count, 7,23,1,"Libor");
    SetNameOfDay($names,$count, 7,23,1,"Liboslav");
    SetNameOfDay($names,$count, 7,24,2,"Kristýna");
    SetNameOfDay($names,$count, 7,24,2,"Kristiána");
    SetNameOfDay($names,$count, 7,25,1,"Jakub");
    SetNameOfDay($names,$count, 7,25,1,"Timur");
    SetNameOfDay($names,$count, 7,26,2,"Anna");
    SetNameOfDay($names,$count, 7,26,2,"Anita");
    SetNameOfDay($names,$count, 7,27,1,"Věroslav");
    SetNameOfDay($names,$count, 7,27,1,"Bertold");
    SetNameOfDay($names,$count, 7,28,1,"Viktor");
    SetNameOfDay($names,$count, 7,28,2,"Alina");
    SetNameOfDay($names,$count, 7,29,2,"Marta");
    SetNameOfDay($names,$count, 7,29,2,"Beatrice");
    SetNameOfDay($names,$count, 7,30,1,"Bořivoj");
    SetNameOfDay($names,$count, 7,30,1,"Vojen");
    SetNameOfDay($names,$count, 7,31,1,"Ignác");
    SetNameOfDay($names,$count, 7,31,1,"Ignát");
    $names['MonthBegin8'] = $count;
    SetNameOfDay($names,$count, 8, 1,1,"Oskar");
    SetNameOfDay($names,$count, 8, 1,1,"Ludomír");
    SetNameOfDay($names,$count, 8, 2,1,"Gustav");
    SetNameOfDay($names,$count, 8, 2,2,"Elfrída");
    SetNameOfDay($names,$count, 8, 3,2,"Miluše");
    SetNameOfDay($names,$count, 8, 3,1,"Nikodém");
    SetNameOfDay($names,$count, 8, 4,1,"Dominik");
    SetNameOfDay($names,$count, 8, 4,2,"Dominika");
    SetNameOfDay($names,$count, 8, 5,1,"Kristián");
    SetNameOfDay($names,$count, 8, 5,1,"Osvald");
    SetNameOfDay($names,$count, 8, 6,2,"Oldřiška");
    SetNameOfDay($names,$count, 8, 6,2,"Ulrika");
    SetNameOfDay($names,$count, 8, 7,2,"Lada");
    SetNameOfDay($names,$count, 8, 7,1,"Kajetán");
    SetNameOfDay($names,$count, 8, 8,1,"Soběslav");
    SetNameOfDay($names,$count, 8, 8,2,"Virgínie");
    SetNameOfDay($names,$count, 8, 9,1,"Roman");
    SetNameOfDay($names,$count, 8, 9,1,"Romeo");
    SetNameOfDay($names,$count, 8,10,1,"Vavřinec");
    SetNameOfDay($names,$count, 8,10,1,"Lars");
    SetNameOfDay($names,$count, 8,11,2,"Zuzana");
    SetNameOfDay($names,$count, 8,11,2,"Filoména");
    SetNameOfDay($names,$count, 8,12,2,"Klára");
    SetNameOfDay($names,$count, 8,12,2,"Jasna");
    SetNameOfDay($names,$count, 8,13,2,"Alena");
    SetNameOfDay($names,$count, 8,13,1,"Sven");
    SetNameOfDay($names,$count, 8,14,1,"Alan");
    SetNameOfDay($names,$count, 8,14,1,"Alen");
    SetNameOfDay($names,$count, 8,15,2,"Hana");
    SetNameOfDay($names,$count, 8,15,2,"Mirela");
    SetNameOfDay($names,$count, 8,16,1,"Jáchym");
    SetNameOfDay($names,$count, 8,16,1,"Abrahám");
    SetNameOfDay($names,$count, 8,17,2,"Petra");
    SetNameOfDay($names,$count, 8,17,2,"Petruše");
    SetNameOfDay($names,$count, 8,18,2,"Helena");
    SetNameOfDay($names,$count, 8,18,2,"Jelena");
    SetNameOfDay($names,$count, 8,19,1,"Ludvík");
    SetNameOfDay($names,$count, 8,19,2,"Ludvíka");
    SetNameOfDay($names,$count, 8,20,1,"Bernard");
    SetNameOfDay($names,$count, 8,20,2,"Bernarda");
    SetNameOfDay($names,$count, 8,21,2,"Johana");
    SetNameOfDay($names,$count, 8,21,2,"Johanka");
    SetNameOfDay($names,$count, 8,22,1,"Bohuslav");
    SetNameOfDay($names,$count, 8,22,1,"Božislav");
    SetNameOfDay($names,$count, 8,23,2,"Sandra");
    SetNameOfDay($names,$count, 8,23,2,"Tekla");
    SetNameOfDay($names,$count, 8,24,1,"Bartoloměj");
    SetNameOfDay($names,$count, 8,24,1,"Natanael");
    SetNameOfDay($names,$count, 8,25,1,"Radim");
    SetNameOfDay($names,$count, 8,25,2,"Elvíra");
    SetNameOfDay($names,$count, 8,26,1,"Luděk");
    SetNameOfDay($names,$count, 8,26,2,"Luďka");
    SetNameOfDay($names,$count, 8,27,1,"Otakar");
    SetNameOfDay($names,$count, 8,27,2,"Otakara");
    SetNameOfDay($names,$count, 8,28,1,"Augustýn");
    SetNameOfDay($names,$count, 8,28,2,"Augustýna");
    SetNameOfDay($names,$count, 8,29,2,"Evelína");
    SetNameOfDay($names,$count, 8,29,1,"Miron");
    SetNameOfDay($names,$count, 8,30,2,"Vladěna");
    SetNameOfDay($names,$count, 8,30,1,"Kim");
    SetNameOfDay($names,$count, 8,31,2,"Pavlína");
    SetNameOfDay($names,$count, 8,31,2,"Bela");
    $names['MonthBegin9'] = $count;
    SetNameOfDay($names,$count, 9, 1,2,"Linda");
    SetNameOfDay($names,$count, 9, 1,1,"Samuel");
    SetNameOfDay($names,$count, 9, 2,2,"Adéla");
    SetNameOfDay($names,$count, 9, 2,2,"Adelína");
    SetNameOfDay($names,$count, 9, 3,1,"Bronislav");
    SetNameOfDay($names,$count, 9, 3,2,"Bronislava");
    SetNameOfDay($names,$count, 9, 4,2,"Jindřiška");
    SetNameOfDay($names,$count, 9, 4,2,"Rozálie");
    SetNameOfDay($names,$count, 9, 5,1,"Boris");
    SetNameOfDay($names,$count, 9, 5,1,"Bojan");
    SetNameOfDay($names,$count, 9, 6,1,"Boleslav");
    SetNameOfDay($names,$count, 9, 6,2,"Boleslava");
    SetNameOfDay($names,$count, 9, 7,2,"Regína");
    SetNameOfDay($names,$count, 9, 7,2,"Gina");
    SetNameOfDay($names,$count, 9, 8,2,"Mariana");
    SetNameOfDay($names,$count, 9, 8,2,"Mariola");
    SetNameOfDay($names,$count, 9, 9,2,"Daniela");
    SetNameOfDay($names,$count, 9, 9,1,"Otmar");
    SetNameOfDay($names,$count, 9,10,2,"Irma");
    SetNameOfDay($names,$count, 9,10,2,"Krasava");
    SetNameOfDay($names,$count, 9,11,2,"Denisa");
    SetNameOfDay($names,$count, 9,11,1,"Denis");
    SetNameOfDay($names,$count, 9,12,2,"Marie");
    SetNameOfDay($names,$count, 9,12,2,"Maja");
    SetNameOfDay($names,$count, 9,13,1,"Lubor");
    SetNameOfDay($names,$count, 9,13,2,"Melinda");
    SetNameOfDay($names,$count, 9,14,2,"Radka");
    SetNameOfDay($names,$count, 9,14,2,"Radoslava");
    SetNameOfDay($names,$count, 9,15,2,"Jolana");
    SetNameOfDay($names,$count, 9,15,2,"Jolanta");
    SetNameOfDay($names,$count, 9,16,2,"Ludmila");
    SetNameOfDay($names,$count, 9,16,2,"Kornélie");
    SetNameOfDay($names,$count, 9,17,2,"Naděžda");
    SetNameOfDay($names,$count, 9,17,2,"Naďa");
    SetNameOfDay($names,$count, 9,18,1,"Kryštof");
    SetNameOfDay($names,$count, 9,18,2,"Ariana");
    SetNameOfDay($names,$count, 9,19,2,"Zita");
    SetNameOfDay($names,$count, 9,19,1,"Konstantýn");
    SetNameOfDay($names,$count, 9,20,1,"Oleg");
    SetNameOfDay($names,$count, 9,20,1,"Helmut");
    SetNameOfDay($names,$count, 9,21,1,"Matouš");
    SetNameOfDay($names,$count, 9,21,2,"Debora");
    SetNameOfDay($names,$count, 9,22,2,"Darina");
    SetNameOfDay($names,$count, 9,22,1,"Moris");
    SetNameOfDay($names,$count, 9,23,2,"Berta");
    SetNameOfDay($names,$count, 9,23,2,"Lina");
    SetNameOfDay($names,$count, 9,24,1,"Jaromír");
    SetNameOfDay($names,$count, 9,24,2,"Jaromíra");
    SetNameOfDay($names,$count, 9,25,2,"Zlata");
    SetNameOfDay($names,$count, 9,25,2,"Zlatoslava");
    SetNameOfDay($names,$count, 9,26,2,"Andrea");
    SetNameOfDay($names,$count, 9,26,2,"Adriana");
    SetNameOfDay($names,$count, 9,27,1,"Jonáš");
    SetNameOfDay($names,$count, 9,27,1,"Damián");
    SetNameOfDay($names,$count, 9,28,1,"Václav");
    SetNameOfDay($names,$count, 9,28,2,"Václava");
    SetNameOfDay($names,$count, 9,28,5,"Den české státnosti");
    SetNameOfDay($names,$count, 9,29,1,"Michal");
    SetNameOfDay($names,$count, 9,29,1,"Michael");
    SetNameOfDay($names,$count, 9,30,1,"Jeroným");
    SetNameOfDay($names,$count, 9,30,2,"Ráchel");
    $names['MonthBegin10'] = $count;
    SetNameOfDay($names,$count,10, 1,1,"Igor");
    SetNameOfDay($names,$count,10, 1,1,"Ivar");
    SetNameOfDay($names,$count,10, 2,2,"Olívie");
    SetNameOfDay($names,$count,10, 2,1,"Oliver");
    SetNameOfDay($names,$count,10, 3,1,"Bohumil");
    SetNameOfDay($names,$count,10, 3,1,"Bohouš");
    SetNameOfDay($names,$count,10, 4,1,"František");
    SetNameOfDay($names,$count,10, 4,1,"Evald");
    SetNameOfDay($names,$count,10, 5,2,"Eliška");
    SetNameOfDay($names,$count,10, 5,2,"Elza");
    SetNameOfDay($names,$count,10, 6,1,"Hanuš");
    SetNameOfDay($names,$count,10, 6,2,"Hanuše");
    SetNameOfDay($names,$count,10, 7,2,"Justýna");
    SetNameOfDay($names,$count,10, 7,1,"Sergej");
    SetNameOfDay($names,$count,10, 8,2,"Věra");
    SetNameOfDay($names,$count,10, 8,2,"Věroslava");
    SetNameOfDay($names,$count,10, 9,1,"Stefan");
    SetNameOfDay($names,$count,10, 9,2,"Sára");
    SetNameOfDay($names,$count,10,10,2,"Marina");
    SetNameOfDay($names,$count,10,10,1,"Marin");
    SetNameOfDay($names,$count,10,11,1,"Andrej");
    SetNameOfDay($names,$count,10,11,1,"Andreas");
    SetNameOfDay($names,$count,10,12,1,"Marcel");
    SetNameOfDay($names,$count,10,12,1,"Edvin");
    SetNameOfDay($names,$count,10,13,2,"Renáta");
    SetNameOfDay($names,$count,10,13,1,"Gerald");
    SetNameOfDay($names,$count,10,14,2,"Agáta");
    SetNameOfDay($names,$count,10,14,2,"Háta");
    SetNameOfDay($names,$count,10,15,2,"Tereza");
    SetNameOfDay($names,$count,10,15,2,"Terezie");
    SetNameOfDay($names,$count,10,16,1,"Havel");
    SetNameOfDay($names,$count,10,16,2,"Galina");
    SetNameOfDay($names,$count,10,17,2,"Hedvika");
    SetNameOfDay($names,$count,10,17,2,"Heda");
    SetNameOfDay($names,$count,10,18,1,"Lukáš");
    SetNameOfDay($names,$count,10,18,2,"Lukáška");
    SetNameOfDay($names,$count,10,19,2,"Michaela");
    SetNameOfDay($names,$count,10,19,2,"Michala");
    SetNameOfDay($names,$count,10,20,1,"Vendelín");
    SetNameOfDay($names,$count,10,20,2,"Eunika");
    SetNameOfDay($names,$count,10,21,2,"Brigita");
    SetNameOfDay($names,$count,10,21,2,"Uršula");
    SetNameOfDay($names,$count,10,22,2,"Sabina");
    SetNameOfDay($names,$count,10,22,2,"Sabrina");
    SetNameOfDay($names,$count,10,23,1,"Teodor");
    SetNameOfDay($names,$count,10,23,1,"Fedor");
    SetNameOfDay($names,$count,10,24,1,"Nina");
    SetNameOfDay($names,$count,10,24,1,"Selina");
    SetNameOfDay($names,$count,10,25,2,"Beata");
    SetNameOfDay($names,$count,10,25,2,"Beáta");
    SetNameOfDay($names,$count,10,26,1,"Erik");
    SetNameOfDay($names,$count,10,26,1,"Erich");
    SetNameOfDay($names,$count,10,27,2,"Šarlota");
    SetNameOfDay($names,$count,10,27,2,"Zoe");
    SetNameOfDay($names,$count,10,28,1,"Alfréd");
    SetNameOfDay($names,$count,10,28,2,"Alfréda");
    SetNameOfDay($names,$count,10,28,5,"Den vzniku samostatného československého státu");
    SetNameOfDay($names,$count,10,29,2,"Silvie");
    SetNameOfDay($names,$count,10,29,2,"Sylva");
    SetNameOfDay($names,$count,10,30,1,"Tadeáš");
    SetNameOfDay($names,$count,10,30,1,"Dimitrij");
    SetNameOfDay($names,$count,10,31,2,"Štěpánka");
    SetNameOfDay($names,$count,10,31,1,"Volfgang");
    $names['MonthBegin11'] = $count;
    SetNameOfDay($names,$count,11, 1,1,"Felix");
    SetNameOfDay($names,$count,11, 1,2,"Felicita");
    SetNameOfDay($names,$count,11, 2,1,"Tobiáš");
    SetNameOfDay($names,$count,11, 2,2,"Jesika");
    SetNameOfDay($names,$count,11, 2,7,"Památka zesnulých");
    SetNameOfDay($names,$count,11, 3,1,"Hubert");
    SetNameOfDay($names,$count,11, 3,1,"Teofil");
    SetNameOfDay($names,$count,11, 4,1,"Karel");
    SetNameOfDay($names,$count,11, 4,2,"Karla");
    SetNameOfDay($names,$count,11, 5,2,"Miriam");
    SetNameOfDay($names,$count,11, 5,1,"Emerich");
    SetNameOfDay($names,$count,11, 6,2,"Liběna");
    SetNameOfDay($names,$count,11, 6,1,"Leonard");
    SetNameOfDay($names,$count,11, 7,2,"Saskie");
    SetNameOfDay($names,$count,11, 7,1,"Engelbert");
    SetNameOfDay($names,$count,11, 8,1,"Bohumír");
    SetNameOfDay($names,$count,11, 8,2,"Bohumíra");
    SetNameOfDay($names,$count,11, 9,1,"Bohdan");
    SetNameOfDay($names,$count,11, 9,1,"Darek");
    SetNameOfDay($names,$count,11,10,1,"Evžen");
    SetNameOfDay($names,$count,11,10,1,"Orest");
    SetNameOfDay($names,$count,11,11,1,"Martin");
    SetNameOfDay($names,$count,11,11,1,"Davor");
    SetNameOfDay($names,$count,11,11,7,"Den válečných veteránů");
    SetNameOfDay($names,$count,11,12,1,"Benedikt");
    SetNameOfDay($names,$count,11,12,1,"Beno");
    SetNameOfDay($names,$count,11,13,1,"Tibor");
    SetNameOfDay($names,$count,11,13,2,"Brenda");
    SetNameOfDay($names,$count,11,14,1,"Sáva");
    SetNameOfDay($names,$count,11,14,1,"Mladen");
    SetNameOfDay($names,$count,11,15,1,"Leopold");
    SetNameOfDay($names,$count,11,15,2,"Leopoldina");
    SetNameOfDay($names,$count,11,16,1,"Otmar");
    SetNameOfDay($names,$count,11,16,1,"Otomar");
    SetNameOfDay($names,$count,11,17,2,"Mahulena");
    SetNameOfDay($names,$count,11,17,2,"Gertruda");
    SetNameOfDay($names,$count,11,17,5,"Den boje za svobodu a demokracii");
    SetNameOfDay($names,$count,11,18,2,"Romana");
    SetNameOfDay($names,$count,11,18,1,"Odon");
    SetNameOfDay($names,$count,11,19,2,"Alžběta");
    SetNameOfDay($names,$count,11,19,2,"Běta");
    SetNameOfDay($names,$count,11,20,2,"Nikola");
    SetNameOfDay($names,$count,11,20,2,"Nikol");
    SetNameOfDay($names,$count,11,21,1,"Albert");
    SetNameOfDay($names,$count,11,21,2,"Alberta");
    SetNameOfDay($names,$count,11,22,2,"Cecílie");
    SetNameOfDay($names,$count,11,22,2,"Cindy");
    SetNameOfDay($names,$count,11,23,1,"Klement");
    SetNameOfDay($names,$count,11,23,2,"Klementýna");
    SetNameOfDay($names,$count,11,24,2,"Emílie");
    SetNameOfDay($names,$count,11,24,2,"Emiliána");
    SetNameOfDay($names,$count,11,25,2,"Kateřina");
    SetNameOfDay($names,$count,11,25,2,"Katrin");
    SetNameOfDay($names,$count,11,26,1,"Artur");
    SetNameOfDay($names,$count,11,26,1,"Kurt");
    SetNameOfDay($names,$count,11,27,2,"Xenie");
    SetNameOfDay($names,$count,11,27,2,"Oxana");
    SetNameOfDay($names,$count,11,28,1,"René");
    SetNameOfDay($names,$count,11,28,1,"Renát");
    SetNameOfDay($names,$count,11,29,2,"Zina");
    SetNameOfDay($names,$count,11,29,2,"Zinaida");
    SetNameOfDay($names,$count,11,30,1,"Ondřej");
    SetNameOfDay($names,$count,11,30,2,"Ondřejka");
    $names['MonthBegin12'] = $count;
    SetNameOfDay($names,$count,12, 1,2,"Iva");
    SetNameOfDay($names,$count,12, 1,1,"Edmund");
    SetNameOfDay($names,$count,12, 2,2,"Blanka");
    SetNameOfDay($names,$count,12, 2,2,"Bibiana");
    SetNameOfDay($names,$count,12, 3,1,"Svatoslav");
    SetNameOfDay($names,$count,12, 3,1,"Svatomír");
    SetNameOfDay($names,$count,12, 4,2,"Barbora");
    SetNameOfDay($names,$count,12, 4,2,"Barbara");
    SetNameOfDay($names,$count,12, 5,2,"Jitka");
    SetNameOfDay($names,$count,12, 5,2,"Liana");
    SetNameOfDay($names,$count,12, 6,1,"Mikuláš");
    SetNameOfDay($names,$count,12, 6,1,"Nikolas");
    SetNameOfDay($names,$count,12, 7,1,"Ambrož");
    SetNameOfDay($names,$count,12, 7,1,"Benjamín");
    SetNameOfDay($names,$count,12, 8,2,"Květoslava");
    SetNameOfDay($names,$count,12, 8,2,"Květomila");
    SetNameOfDay($names,$count,12, 9,1,"Vratislav");
    SetNameOfDay($names,$count,12, 9,2,"Vratislava");
    SetNameOfDay($names,$count,12,10,2,"Julie");
    SetNameOfDay($names,$count,12,10,2,"Juliána");
    SetNameOfDay($names,$count,12,11,2,"Dana");
    SetNameOfDay($names,$count,12,11,2,"Danuše");
    SetNameOfDay($names,$count,12,12,2,"Simona");
    SetNameOfDay($names,$count,12,12,2,"Šimona");
    SetNameOfDay($names,$count,12,13,2,"Lucie");
    SetNameOfDay($names,$count,12,13,1,"Lucián");
    SetNameOfDay($names,$count,12,14,2,"Lýdie");
    SetNameOfDay($names,$count,12,14,2,"Livie");
    SetNameOfDay($names,$count,12,15,2,"Radana");
    SetNameOfDay($names,$count,12,15,1,"Radan");
    SetNameOfDay($names,$count,12,16,2,"Albína");
    SetNameOfDay($names,$count,12,16,1,"Albín");
    SetNameOfDay($names,$count,12,17,1,"Daniel");
    SetNameOfDay($names,$count,12,17,1,"Dan");
    SetNameOfDay($names,$count,12,18,1,"Miloslav");
    SetNameOfDay($names,$count,12,18,1,"Milorad");
    SetNameOfDay($names,$count,12,19,2,"Ester");
    SetNameOfDay($names,$count,12,19,1,"Darius");
    SetNameOfDay($names,$count,12,20,2,"Dagmar");
    SetNameOfDay($names,$count,12,20,1,"Dag");
    SetNameOfDay($names,$count,12,21,2,"Natálie");
    SetNameOfDay($names,$count,12,21,1,"Noel");
    SetNameOfDay($names,$count,12,22,1,"Šimon");
    SetNameOfDay($names,$count,12,22,1,"Simon");
    SetNameOfDay($names,$count,12,23,2,"Vlasta");
    SetNameOfDay($names,$count,12,23,2,"Niké");
    SetNameOfDay($names,$count,12,24,1,"Adam a Eva");
    SetNameOfDay($names,$count,12,24,5,"Štědrý den");
    SetNameOfDay($names,$count,12,25,1,"Boží hod vánoční");
    SetNameOfDay($names,$count,12,25,5,"1. svátek vánoční");
    SetNameOfDay($names,$count,12,26,1,"Štěpán");
    SetNameOfDay($names,$count,12,26,1,"Sokrat");
    SetNameOfDay($names,$count,12,26,5,"2. svátek vánoční");
    SetNameOfDay($names,$count,12,27,2,"Žaneta");
    SetNameOfDay($names,$count,12,27,2,"Melánie");
    SetNameOfDay($names,$count,12,28,2,"Bohumila");
    SetNameOfDay($names,$count,12,28,2,"Donika");
    SetNameOfDay($names,$count,12,29,2,"Judita");
    SetNameOfDay($names,$count,12,29,1,"Natan");
    SetNameOfDay($names,$count,12,30,1,"David");
    SetNameOfDay($names,$count,12,30,2,"Davida");
    SetNameOfDay($names,$count,12,31,1,"Silvestr");
    SetNameOfDay($names,$count,12,31,1,"Horst");
    $names['Count'] = $count;
    return $names;}
function NameDay($d="") {
    $name = "";
    if($d == "") { $d = Date("d.m."); }
    if($d == "01.01.") { $name = "Nový rok; Den obnovy samostatnosti českého státu"; }
    if($d == "02.01.") { $name = "Karina"; }
    if($d == "03.01.") { $name = "Radmila"; }
    if($d == "04.01.") { $name = "Diana"; }
    if($d == "05.01.") { $name = "Dalimil"; }
    if($d == "06.01.") { $name = "Tři králové"; }
    if($d == "07.01.") { $name = "Vilma"; }
    if($d == "08.01.") { $name = "Čestmír"; }
    if($d == "09.01.") { $name = "Vladan"; }
    if($d == "10.01.") { $name = "Břetislav"; }
    if($d == "11.01.") { $name = "Bohdana"; }
    if($d == "12.01.") { $name = "Pravoslav"; }
    if($d == "13.01.") { $name = "Edita"; }
    if($d == "14.01.") { $name = "Radovan"; }
    if($d == "15.01.") { $name = "Alice"; }
    if($d == "16.01.") { $name = "Ctirad"; }
    if($d == "17.01.") { $name = "Drahoslav"; }
    if($d == "18.01.") { $name = "Vladislav"; }
    if($d == "19.01.") { $name = "Doubravka"; }
    if($d == "20.01.") { $name = "Ilona"; }
    if($d == "21.01.") { $name = "Běla"; }
    if($d == "22.01.") { $name = "Slavomír"; }
    if($d == "23.01.") { $name = "Zdeněk"; }
    if($d == "24.01.") { $name = "Milena"; }
    if($d == "25.01.") { $name = "Miloš"; }
    if($d == "26.01.") { $name = "Zora"; }
    if($d == "27.01.") { $name = "Ingrid"; }
    if($d == "28.01.") { $name = "Otýlie"; }
    if($d == "29.01.") { $name = "Zdislava"; }
    if($d == "30.01.") { $name = "Robin"; }
    if($d == "31.01.") { $name = "Marika"; }
    if($d == "01.02.") { $name = "Hynek"; }
    if($d == "02.02.") { $name = "Nela"; }
    if($d == "03.02.") { $name = "Blažej"; }
    if($d == "04.02.") { $name = "Jarmila"; }
    if($d == "05.02.") { $name = "Dobromila"; }
    if($d == "06.02.") { $name = "Vanda"; }
    if($d == "07.02.") { $name = "Veronika"; }
    if($d == "08.02.") { $name = "Milada"; }
    if($d == "09.02.") { $name = "Apolena"; }
    if($d == "10.02.") { $name = "Mojmír"; }
    if($d == "11.02.") { $name = "Božena"; }
    if($d == "12.02.") { $name = "Slavěna"; }
    if($d == "13.02.") { $name = "Věnceslav"; }
    if($d == "14.02.") { $name = "Valentýn"; }
    if($d == "15.02.") { $name = "Jiřina"; }
    if($d == "16.02.") { $name = "Ljuba"; }
    if($d == "17.02.") { $name = "Miloslava"; }
    if($d == "18.02.") { $name = "Gizela"; }
    if($d == "19.02.") { $name = "Patrik"; }
    if($d == "20.02.") { $name = "Oldřich"; }
    if($d == "21.02.") { $name = "Lenka"; }
    if($d == "22.02.") { $name = "Petr"; }
    if($d == "23.02.") { $name = "Svatopluk"; }
    if($d == "24.02.") { $name = "Matěj"; }
    if($d == "25.02.") { $name = "Liliana"; }
    if($d == "26.02.") { $name = "Dora"; }
    if($d == "27.02.") { $name = "Alexandr"; }
    if($d == "28.02.") { $name = "Lumír"; }
    if($d == "29.02.") { $name = "Horymír"; }
    if($d == "01.03.") { $name = "Bedřich"; }
    if($d == "02.03.") { $name = "Anežka"; }
    if($d == "03.03.") { $name = "Kamil"; }
    if($d == "04.03.") { $name = "Stela"; }
    if($d == "05.03.") { $name = "Kazimír"; }
    if($d == "06.03.") { $name = "Miroslav"; }
    if($d == "07.03.") { $name = "Tomáš"; }
    if($d == "08.03.") { $name = "Gabriela"; }
    if($d == "09.03.") { $name = "Františka"; }
    if($d == "10.03.") { $name = "Viktorie"; }
    if($d == "11.03.") { $name = "Anděla"; }
    if($d == "12.03.") { $name = "Řehoř; Den přijetí ČR do NATO"; }
    if($d == "13.03.") { $name = "Růžena"; }
    if($d == "14.03.") { $name = "Rút"; }
    if($d == "15.03.") { $name = "Ida"; }
    if($d == "16.03.") { $name = "Elena"; }
    if($d == "17.03.") { $name = "Vlastimil"; }
    if($d == "18.03.") { $name = "Eduard"; }
    if($d == "19.03.") { $name = "Josef"; }
    if($d == "20.03.") { $name = "Světlana"; }
    if($d == "21.03.") { $name = "Radek"; }
    if($d == "22.03.") { $name = "Leona"; }
    if($d == "23.03.") { $name = "Ivona"; }
    if($d == "24.03.") { $name = "Gabriel"; }
    if($d == "25.03.") { $name = "Marián"; }
    if($d == "26.03.") { $name = "Emanuel"; }
    if($d == "27.03.") { $name = "Dita"; }
    if($d == "28.03.") { $name = "Soňa"; }
    if($d == "29.03.") { $name = "Taťána"; }
    if($d == "30.03.") { $name = "Arnošt"; }
    if($d == "31.03.") { $name = "Kvido"; }
    if($d == "01.04.") { $name = "Hugo"; }
    if($d == "02.04.") { $name = "Erika"; }
    if($d == "03.04.") { $name = "Richard"; }
    if($d == "04.04.") { $name = "Ivana"; }
    if($d == "05.04.") { $name = "Miroslava"; }
    if($d == "06.04.") { $name = "Vendula"; }
    if($d == "07.04.") { $name = "Heřman"; }
    if($d == "08.04.") { $name = "Ema"; }
    if($d == "09.04.") { $name = "Dušan"; }
    if($d == "10.04.") { $name = "Darja"; }
    if($d == "11.04.") { $name = "Izabela"; }
    if($d == "12.04.") { $name = "Julius"; }
    if($d == "13.04.") { $name = "Aleš"; }
    if($d == "14.04.") { $name = "Vincenc"; }
    if($d == "15.04.") { $name = "Anastázie"; }
    if($d == "16.04.") { $name = "Irena"; }
    if($d == "17.04.") { $name = "Rudolf"; }
    if($d == "18.04.") { $name = "Valérie"; }
    if($d == "19.04.") { $name = "Rostislav"; }
    if($d == "20.04.") { $name = "Marcela"; }
    if($d == "21.04.") { $name = "Alexandra"; }
    if($d == "22.04.") { $name = "Evženie"; }
    if($d == "23.04.") { $name = "Vojtěch"; }
    if($d == "24.04.") { $name = "Jiří"; }
    if($d == "25.04.") { $name = "Marek"; }
    if($d == "26.04.") { $name = "Oto"; }
    if($d == "27.04.") { $name = "Jaroslav"; }
    if($d == "28.04.") { $name = "Vlastislav"; }
    if($d == "29.04.") { $name = "Robert"; }
    if($d == "30.04.") { $name = "Blahoslav"; }
    if($d == "01.05.") { $name = "Svátek práce"; }
    if($d == "02.05.") { $name = "Zikmund"; }
    if($d == "03.05.") { $name = "Alexej"; }
    if($d == "04.05.") { $name = "Květoslav"; }
    if($d == "05.05.") { $name = "Klaudie; Květnové povstání českého lidu"; }
    if($d == "06.05.") { $name = "Radoslav"; }
    if($d == "07.05.") { $name = "Stanislav"; }
    if($d == "08.05.") { $name = "Den osvobození od fašismu"; }
    if($d == "09.05.") { $name = "Ctibor"; }
    if($d == "10.05.") { $name = "Blažena"; }
    if($d == "11.05.") { $name = "Svatava"; }
    if($d == "12.05.") { $name = "Pankrác"; }
    if($d == "13.05.") { $name = "Servác"; }
    if($d == "14.05.") { $name = "Bonifác"; }
    if($d == "15.05.") { $name = "Žofie"; }
    if($d == "16.05.") { $name = "Přemysl"; }
    if($d == "17.05.") { $name = "Aneta"; }
    if($d == "18.05.") { $name = "Nataša"; }
    if($d == "19.05.") { $name = "Ivo"; }
    if($d == "20.05.") { $name = "Zbyšek"; }
    if($d == "21.05.") { $name = "Monika"; }
    if($d == "22.05.") { $name = "Emil"; }
    if($d == "23.05.") { $name = "Vladimír"; }
    if($d == "24.05.") { $name = "Jana"; }
    if($d == "25.05.") { $name = "Viola"; }
    if($d == "26.05.") { $name = "Filip"; }
    if($d == "27.05.") { $name = "Valdemar"; }
    if($d == "28.05.") { $name = "Vilém"; }
    if($d == "29.05.") { $name = "Maxim"; }
    if($d == "30.05.") { $name = "Ferdinand"; }
    if($d == "31.05.") { $name = "Kamila"; }
    if($d == "01.06.") { $name = "Laura"; }
    if($d == "02.06.") { $name = "Jarmil"; }
    if($d == "03.06.") { $name = "Tamara"; }
    if($d == "04.06.") { $name = "Dalibor"; }
    if($d == "05.06.") { $name = "Dobroslav"; }
    if($d == "06.06.") { $name = "Norbert"; }
    if($d == "07.06.") { $name = "Iveta"; }
    if($d == "08.06.") { $name = "Medard"; }
    if($d == "09.06.") { $name = "Stanislava"; }
    if($d == "10.06.") { $name = "Gita"; }
    if($d == "11.06.") { $name = "Bruno"; }
    if($d == "12.06.") { $name = "Antonie"; }
    if($d == "13.06.") { $name = "Antonín"; }
    if($d == "14.06.") { $name = "Roland"; }
    if($d == "15.06.") { $name = "Vít"; }
    if($d == "16.06.") { $name = "Zbyněk"; }
    if($d == "17.06.") { $name = "Adolf"; }
    if($d == "18.06.") { $name = "Milan"; }
    if($d == "19.06.") { $name = "Leoš"; }
    if($d == "20.06.") { $name = "Květa"; }
    if($d == "21.06.") { $name = "Alois"; }
    if($d == "22.06.") { $name = "Pavla"; }
    if($d == "23.06.") { $name = "Zdeňka"; }
    if($d == "24.06.") { $name = "Jan"; }
    if($d == "25.06.") { $name = "Ivan"; }
    if($d == "26.06.") { $name = "Adriana"; }
    if($d == "27.06.") { $name = "Ladislav"; }
    if($d == "28.06.") { $name = "Lubomír"; }
    if($d == "29.06.") { $name = "Petr a Pavel"; }
    if($d == "30.06.") { $name = "Šárka"; }
    if($d == "01.07.") { $name = "Jaroslava"; }
    if($d == "02.07.") { $name = "Patricie"; }
    if($d == "03.07.") { $name = "Radomír"; }
    if($d == "04.07.") { $name = "Prokop"; }
    if($d == "05.07.") { $name = "Den slovanských věrozvěstů Cyrila a Metoděje"; }
    if($d == "06.07.") { $name = "Den upálení mistra Jana Husa"; }
    if($d == "07.07.") { $name = "Bohuslava"; }
    if($d == "08.07.") { $name = "Nora"; }
    if($d == "09.07.") { $name = "Drahoslava"; }
    if($d == "10.07.") { $name = "Libuše"; }
    if($d == "11.07.") { $name = "Olga"; }
    if($d == "12.07.") { $name = "Bořek"; }
    if($d == "13.07.") { $name = "Markéta"; }
    if($d == "14.07.") { $name = "Karolína"; }
    if($d == "15.07.") { $name = "Jindřich"; }
    if($d == "16.07.") { $name = "Luboš"; }
    if($d == "17.07.") { $name = "Martina"; }
    if($d == "18.07.") { $name = "Drahomíra"; }
    if($d == "19.07.") { $name = "Čeněk"; }
    if($d == "20.07.") { $name = "Ilja"; }
    if($d == "21.07.") { $name = "Vítězslav"; }
    if($d == "22.07.") { $name = "Magdaléna"; }
    if($d == "23.07.") { $name = "Libor"; }
    if($d == "24.07.") { $name = "Kristýna"; }
    if($d == "25.07.") { $name = "Jakub"; }
    if($d == "26.07.") { $name = "Anna"; }
    if($d == "27.07.") { $name = "Věroslav"; }
    if($d == "28.07.") { $name = "Viktor"; }
    if($d == "29.07.") { $name = "Marta"; }
    if($d == "30.07.") { $name = "Bořivoj"; }
    if($d == "31.07.") { $name = "Ignác"; }
    if($d == "01.08.") { $name = "Oskar"; }
    if($d == "02.08.") { $name = "Gustav"; }
    if($d == "03.08.") { $name = "Miluše"; }
    if($d == "04.08.") { $name = "Dominik"; }
    if($d == "05.08.") { $name = "Kristián"; }
    if($d == "06.08.") { $name = "Oldřiška"; }
    if($d == "07.08.") { $name = "Lada"; }
    if($d == "08.08.") { $name = "Soběslav"; }
    if($d == "09.08.") { $name = "Roman"; }
    if($d == "10.08.") { $name = "Vavřinec"; }
    if($d == "11.08.") { $name = "Zuzana"; }
    if($d == "12.08.") { $name = "Klára"; }
    if($d == "13.08.") { $name = "Alena"; }
    if($d == "14.08.") { $name = "Alan"; }
    if($d == "15.08.") { $name = "Hana"; }
    if($d == "16.08.") { $name = "Jáchym"; }
    if($d == "17.08.") { $name = "Petra"; }
    if($d == "18.08.") { $name = "Helena"; }
    if($d == "19.08.") { $name = "Ludvík"; }
    if($d == "20.08.") { $name = "Bernard"; }
    if($d == "21.08.") { $name = "Johana"; }
    if($d == "22.08.") { $name = "Bohuslav"; }
    if($d == "23.08.") { $name = "Sandra"; }
    if($d == "24.08.") { $name = "Bartoloměj"; }
    if($d == "25.08.") { $name = "Radim"; }
    if($d == "26.08.") { $name = "Luďěk"; }
    if($d == "27.08.") { $name = "Otakar"; }
    if($d == "28.08.") { $name = "Augustýn"; }
    if($d == "29.08.") { $name = "Evelína"; }
    if($d == "30.08.") { $name = "Vladěna"; }
    if($d == "31.08.") { $name = "Pavlína"; }
    if($d == "01.09.") { $name = "Linda"; }
    if($d == "02.09.") { $name = "Adéla"; }
    if($d == "03.09.") { $name = "Bronislav"; }
    if($d == "04.09.") { $name = "Jindřiška"; }
    if($d == "05.09.") { $name = "Boris"; }
    if($d == "06.09.") { $name = "Boleslav"; }
    if($d == "07.09.") { $name = "Regína"; }
    if($d == "08.09.") { $name = "Mariana"; }
    if($d == "09.09.") { $name = "Daniela"; }
    if($d == "10.09.") { $name = "Irma"; }
    if($d == "11.09.") { $name = "Denisa"; }
    if($d == "12.09.") { $name = "Marie"; }
    if($d == "13.09.") { $name = "Lubor"; }
    if($d == "14.09.") { $name = "Radka"; }
    if($d == "15.09.") { $name = "Jolana"; }
    if($d == "16.09.") { $name = "Ludmila"; }
    if($d == "17.09.") { $name = "Naděžda"; }
    if($d == "18.09.") { $name = "Kryštof"; }
    if($d == "19.09.") { $name = "Zita"; }
    if($d == "20.09.") { $name = "Oleg"; }
    if($d == "21.09.") { $name = "Matouš"; }
    if($d == "22.09.") { $name = "Darina"; }
    if($d == "23.09.") { $name = "Berta"; }
    if($d == "24.09.") { $name = "Jaromír"; }
    if($d == "25.09.") { $name = "Zlata"; }
    if($d == "26.09.") { $name = "Andrea"; }
    if($d == "27.09.") { $name = "Jonáš"; }
    if($d == "28.09.") { $name = "Václav; Den české státnosti"; }
    if($d == "29.09.") { $name = "Michal"; }
    if($d == "30.09.") { $name = "Jeroným"; }
    if($d == "01.10.") { $name = "Igor"; }
    if($d == "02.10.") { $name = "Olívie/Oliver"; }
    if($d == "03.10.") { $name = "Bohumil"; }
    if($d == "04.10.") { $name = "František"; }
    if($d == "05.10.") { $name = "Eliška"; }
    if($d == "06.10.") { $name = "Hanuš"; }
    if($d == "07.10.") { $name = "Sergej"; }
    if($d == "08.10.") { $name = "Věra"; }
    if($d == "09.10.") { $name = "Štefan"; }
    if($d == "10.10.") { $name = "Marina"; }
    if($d == "11.10.") { $name = "Andrej"; }
    if($d == "12.10.") { $name = "Marcel"; }
    if($d == "13.10.") { $name = "Renáta"; }
    if($d == "14.10.") { $name = "Agáta"; }
    if($d == "15.10.") { $name = "Tereza"; }
    if($d == "16.10.") { $name = "Havel"; }
    if($d == "17.10.") { $name = "Hedvika"; }
    if($d == "18.10.") { $name = "Lukáš"; }
    if($d == "19.10.") { $name = "Michaela"; }
    if($d == "20.10.") { $name = "Vendelín"; }
    if($d == "21.10.") { $name = "Brigita"; }
    if($d == "22.10.") { $name = "Sabina"; }
    if($d == "23.10.") { $name = "Teodor"; }
    if($d == "24.10.") { $name = "Nina"; }
    if($d == "25.10.") { $name = "Beáta"; }
    if($d == "26.10.") { $name = "Erik"; }
    if($d == "27.10.") { $name = "Zoja"; }
    if($d == "28.10.") { $name = "Den vzniku samostatného československého státu"; }
    if($d == "29.10.") { $name = "Silvie"; }
    if($d == "30.10.") { $name = "Tadeáš"; }
    if($d == "31.10.") { $name = "Štěpánka"; }
    if($d == "01.11.") { $name = "Felix"; }
    if($d == "02.11.") { $name = "Památka zesnulých"; }
    if($d == "03.11.") { $name = "Hubert"; }
    if($d == "04.11.") { $name = "Karel"; }
    if($d == "05.11.") { $name = "Miriam"; }
    if($d == "06.11.") { $name = "Liběna"; }
    if($d == "07.11.") { $name = "Saskie"; }
    if($d == "08.11.") { $name = "Bohumír"; }
    if($d == "09.11.") { $name = "Bohdan"; }
    if($d == "10.11.") { $name = "Evžen"; }
    if($d == "11.11.") { $name = "Martin"; }
    if($d == "12.11.") { $name = "Benedikt"; }
    if($d == "13.11.") { $name = "Tibor"; }
    if($d == "14.11.") { $name = "Sáva"; }
    if($d == "15.11.") { $name = "Leopold"; }
    if($d == "16.11.") { $name = "Otmar"; }
    if($d == "17.11.") { $name = "Mahulena; Den boje za svobodu a demokracii"; }
    if($d == "18.11.") { $name = "Romana"; }
    if($d == "19.11.") { $name = "Alžběta"; }
    if($d == "20.11.") { $name = "Nikola"; }
    if($d == "21.11.") { $name = "Albert"; }
    if($d == "22.11.") { $name = "Cecílie"; }
    if($d == "23.11.") { $name = "Klement"; }
    if($d == "24.11.") { $name = "Emílie"; }
    if($d == "25.11.") { $name = "Kateřina"; }
    if($d == "26.11.") { $name = "Artur"; }
    if($d == "27.11.") { $name = "Xenie"; }
    if($d == "28.11.") { $name = "René"; }
    if($d == "29.11.") { $name = "Zina"; }
    if($d == "30.11.") { $name = "Ondřej"; }
    if($d == "01.12.") { $name = "Iva"; }
    if($d == "02.12.") { $name = "Blanka"; }
    if($d == "03.12.") { $name = "Svatoslav"; }
    if($d == "04.12.") { $name = "Barbora"; }
    if($d == "05.12.") { $name = "Jitka"; }
    if($d == "06.12.") { $name = "Mikuláš"; }
    if($d == "07.12.") { $name = "Ambrož"; }
    if($d == "08.12.") { $name = "Květoslava"; }
    if($d == "09.12.") { $name = "Vratislav"; }
    if($d == "10.12.") { $name = "Julie"; }
    if($d == "11.12.") { $name = "Dana"; }
    if($d == "12.12.") { $name = "Simona"; }
    if($d == "13.12.") { $name = "Lucie"; }
    if($d == "14.12.") { $name = "Lýdie"; }
    if($d == "15.12.") { $name = "Radana"; }
    if($d == "16.12.") { $name = "Albína"; }
    if($d == "17.12.") { $name = "Daniel"; }
    if($d == "18.12.") { $name = "Miloslav"; }
    if($d == "19.12.") { $name = "Ester"; }
    if($d == "20.12.") { $name = "Dagmar"; }
    if($d == "21.12.") { $name = "Natálie"; }
    if($d == "22.12.") { $name = "Šimon"; }
    if($d == "23.12.") { $name = "Vlasta"; }
    if($d == "24.12.") { $name = "Adam a Eva; Štědrý den"; }
    if($d == "25.12.") { $name = "1. svátek vánoční"; }
    if($d == "26.12.") { $name = "Štěpán; 2. svátek vánoční"; }
    if($d == "27.12.") { $name = "Žaneta"; }
    if($d == "28.12.") { $name = "Bohumila"; }
    if($d == "29.12.") { $name = "Judita"; }
    if($d == "30.12.") { $name = "David"; }
    if($d == "31.12.") { $name = "Silvestr"; }
    return $name;}
$MTPS->Path = UrlPathToArray(utf8_substr($_SERVER['REQUEST_URI'],0,$len),$MTPS->PathCount,$language_in_path);
if(!$ApiCall && $MTPS->PathCount > 0 && $MTPS->Path[0] == "MTPSCreateTables") { $MTPS->CreateTables = true; } else { $MTPS->CreateTables = false; }
if(IsSet($MTPS->Path[0])) { $MTPS->PathOne = strtolower($MTPS->Path[0]); }
if(IsSet($MTPS->Path[1])) { $MTPS->PathTwo = strtolower($MTPS->Path[1]); }
if(IsSet($MTPS->Path[2])) { $MTPS->PathThree = strtolower($MTPS->Path[2]); }
if(IsSet($MTPS->Path[3])) { $MTPS->PathFour = strtolower($MTPS->Path[3]); }
if(IsSet($MTPS->Path[4])) { $MTPS->PathFive = strtolower($MTPS->Path[4]); }
if(@file_exists($fileWEB."settings.php")) { include_once($fileWEB."settings.php"); }
else { die("<b>Fatal error:</b> File ".$fileWEB."settings.php doesn't exist!<br />Host: ".$_SERVER['HTTP_HOST']); }
if(!IsSet($MTPS->MySQL_Name) || $MTPS->MySQL_Name == "") { die("<b>Fatal error:</b> Database value MTPS->MySQL_Name is not set!<br />Host: ".$_SERVER['HTTP_HOST']); }
if(!IsSet($MTPS->MySQL_User) || $MTPS->MySQL_User == "") { die("<b>Fatal error:</b> Database value MTPS->MySQL_User is not set!<br />Host: ".$_SERVER['HTTP_HOST']); }
if(!IsSet($MTPS->MySQL_Pass) || $MTPS->MySQL_Pass == "") { die("<b>Fatal error:</b> Database value MTPS->MySQL_Pass is not set!<br />Host: ".$_SERVER['HTTP_HOST']); }
if(!IsSet($MTPS->MySQL_Host) || $MTPS->MySQL_Host == "") { die("<b>Fatal error:</b> Database value MTPS->MySQL_Host is not set!<br />Host: ".$_SERVER['HTTP_HOST']); }
$MTPS->Path = UrlPathToArray(utf8_substr($_SERVER['REQUEST_URI'],0,$len),$MTPS->PathCount,$language_in_path);
if(!$ApiCall && $MTPS->PathCount > 0 && $MTPS->Path[0] == "MTPSCreateTables") { $MTPS->CreateTables = true; } else { $MTPS->CreateTables = false; }
if(IsSet($MTPS->Path[0])) { $MTPS->PathOne = strtolower($MTPS->Path[0]); }
if(IsSet($MTPS->Path[1])) { $MTPS->PathTwo = strtolower($MTPS->Path[1]); }
if(IsSet($MTPS->Path[2])) { $MTPS->PathThree = strtolower($MTPS->Path[2]); }
if(IsSet($MTPS->Path[3])) { $MTPS->PathFour = strtolower($MTPS->Path[3]); }
if(IsSet($MTPS->Path[4])) { $MTPS->PathFive = strtolower($MTPS->Path[4]); }
$GLOBALS['g_FormID'] = 0;
$GLOBALS['TodayStarts'] = mktime(0,0,0,date("n"),date("j"),date("Y"));
$GLOBALS['TodayEnds'] = mktime(23,59,59,date("n"),date("j"),date("Y"));
$GLOBALS['TodayCountHours'] = (($GLOBALS['TodayEnds']+1) - $GLOBALS['TodayStarts']) / 60 / 60;
$GLOBALS['REPORT_COUNT'] = 0;
$GLOBALS['REPORT_TEXT'] = array();
$GLOBALS['REPORT_TYPE'] = array();
$GLOBALS['NavigationLastURL'] = "";
$stringsList = array();
$stringsCount = 0;
$ErrorHandlerCount = 0;

function ErrorHandler($errno, $errstr, $errfile, $errline) {
    if(!(error_reporting() & $errno)) { return; }
    $str = "";
    $GLOBALS['ErrorHandlerCount']++;
    switch($errno) {
        case 2: $str.= "WARNING: "; break;
        case 8: $str.= "NOTICE: "; break;
        case 256: $str.= "USER_ERROR: "; break;
        case 512: $str.= "USER_WARNING: "; break;
        case 1024: $str.= "USER_NOTICE: "; break;
        case 4096: $str.= "RECOVERABLE_ERROR: "; break;
        case 8191: $str.= "ALL "; break;
        default: $str.= "UNDEFINED ($errno): "; break;}
    $str.= "<b>$errstr</b> in file \"$errfile\" [$errline] (HTTP_HOST: ".$_SERVER['HTTP_HOST'].")<br />\n";
    AddError($str);
    WriteLog($str);
    return true;}
set_error_handler("ErrorHandler");
function FindBetween($buf,$first,$second,&$start=0,&$posX=0,&$pos2=0) {
    $text = false;
    $pos2 = false;
    $dl = strlen($first);
    if(($pos = strpos($buf,$first,$posX)) !== false) {
        if(($pos2 = strpos($buf,$second,$pos+$dl)) !== false) {
            $dl3 = $pos2 - $pos - $dl;
            $text = substr($buf,$pos+$dl,$dl3);}
        $start = $pos;
        $posX = $pos + $dl;}
    return $text;}
function GetPath($file_with_path) {
    $pos = 0;
    $lastpos = 0;
    while(($pos = strpos($file_with_path,"/",$lastpos)) !== false) {
        $lastpos = $pos+1;}
    return substr($file_with_path,0,$lastpos);}
function IsAlphabetCharacter($char) {
    $list = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
    for($aa=0; $aa<strlen($list); $aa++) {
        if($char == $list[$aa]) { return true; }}
    return false;}
function IndexOneString($content,$first,$last,$is_comment=0) {
    global $stringsList, $stringsCount;
    $stringsList[$stringsCount] = new stdClass;
    $stringsList[$stringsCount]->begin = $first + 1;
    $stringsList[$stringsCount]->end = $last;
    $stringsList[$stringsCount]->comment = $is_comment;
    $stringsCount++;}
function IsInsideString($pos,$content) {
    global $stringsList, $stringsCount;
    for($aa=0; $aa<$stringsCount; $aa++) {
        if($pos >= $stringsList[$aa]->begin && $pos <= $stringsList[$aa]->end) {
            return true;}}
    return false;}
function IndexAllStringsAndComments($content) {
    global $stringsList, $stringsCount;
    $stringsList = array();
    $stringsCount = 0;
    $chr0 = ord("/");
    $chr1 = ord("\"");
    $chr2 = ord("'");
    $actual_chr = 0;
    $first = -1;
    $last = -1;
    $len = strlen($content);
    $is_comment = 0;
    for($aa=0; $aa<$len; $aa++) {
        $found = false;
        if($actual_chr == 0 && ord($content[$aa]) == $chr0 && ord($content[$aa+1]) == $chr0) {
            $is_comment = 1;
            $first = $aa;
            for($bb=1; $bb<$len-$aa; $bb++) {
                if(ord($content[$aa+$bb]) == ord("\n") || ord($content[$aa+$bb]) == ord("\r")) {
                    $last = $aa+$bb;
                    $aa+= $bb+1;
                    break;}}}
        else if($actual_chr == 0 && ord($content[$aa]) == $chr0 && ord($content[$aa+1]) == ord("*")) {
            $is_comment = 2;
            $first = $aa;
            for($bb=1; $bb<$len-$aa; $bb++) {
                if(ord($content[$aa+$bb]) == ord("*") && ord($content[$aa+$bb+1]) == $chr0) {
                    $last = $aa+$bb+1;
                    $aa+= $bb+1;
                    break;}}}
        else if((($actual_chr == 0 && (ord($content[$aa]) == $chr1 || ord($content[$aa]) == $chr2)) || ($actual_chr != 0 && (ord($content[$aa]) == $actual_chr))) && !IsInsideString($aa,$content)) {
            $actual_chr = ord($content[$aa]);
            $found = true;
            if($aa > 0) {
                if(ord($content[$aa-1]) == ord("\\")) {
                    $found = false;
                    if($aa > 1 && ord($content[$aa-2]) == ord("\\")) {
                        $found = true;
                        if($aa > 2 && ord($content[$aa-3]) == ord("\\")) {
                            $found = false;}}}
                if(ord($content[$aa]) == $chr2 && IsAlphabetCharacter($content[$aa-1]) && IsAlphabetCharacter($content[$aa+1])) {
                    $found = false;}}}
        if($found) {
            if($first == -1) { $first = $aa; }
            else if($last == -1) { $last = $aa; }}
        if($first > -1 && $last > -1) {
            IndexOneString($content,$first,$last,$is_comment);
            $first = -1;
            $last = -1;
            $actual_chr = 0;
            $is_comment = 0;}}}
function DeleteAllComments($content) {
    global $stringsList, $stringsCount;
    IndexAllStringsAndComments($content);
    $len = strlen($content);
    $new = "";
    $last_begin = 0;
    for($aa=0; $aa<$stringsCount; $aa++) {
        if($stringsList[$aa]->comment > 0) {
            $new.= substr($content,$last_begin,($stringsList[$aa]->begin - $last_begin - 1));
            $last_begin = $stringsList[$aa]->end + 1;}}
    $new.= substr($content,$last_begin);
    return $new;}
function NewRow($table_name,$item_id,&$response,$created_by_user_id=true) {
    global $DB;
    if($item_id <= 0) {
        if(IsSet($data)) { unset($data); }
        if($created_by_user_id) {
            $data['CreatedByUserID'] = GetUserAccountID();}
        $item_id = $DB->Insert($table_name,$data,$response);}
    return $item_id;}
/*function getRowById($table_name,$id) {
    if(($rows = $GLOBALS['DB']->Select($table_name,"`ID`=".DBText($id),$count)) !== false && $count > 0) {
        return $rows[0];}
    return false;}
function getRowByName($table_name,$name) {
    if(($rows = $GLOBALS['DB']->Select($table_name,"`Name`='".DBText($name)."'",$count)) !== false && $count > 0) {
        return $rows[0];}
    return false;}
function getRowByTitle($table_name,$title,$id=0) {
    if($id > 0) { $cnd = " AND `ID`!=".DBText($id); } else { $cnd = ""; }
    if(($rows = $GLOBALS['DB']->Select($table_name,"`Title` = '".DBText($title)."'".$cnd,$count)) !== false && $count > 0) {
        return $rows[0];}
    return false;}*/
function getListOfRows($table_name,$col_name,$col_operator,$col_value,&$count) {
    $count = 0;
    if(($rows = $GLOBALS['DB']->Select($table_name,"`".DBText($col_name)."` ".DBText($col_operator)." '".DBText($col_value)."'",$count)) !== false && $count > 0) {
        return $rows;}
    return false;}
function ToNum($num) {
    $num = str_replace (chr(32),"",$num);
    return str_replace (",",".",$num);}
function StringLen($text) {
    return mb_strlen($text,$GLOBALS['MTPS']->Charset);}
function RepairUTF8($text) {
    $text = str_replace("\x1F","",$text);
    return $text;}
function StrToHex($string){
    $hex = '';
    for($i=0; $i<strlen($string); $i++) {
        $ord = ord($string[$i]);
        $hexCode = dechex($ord);
        $hex.= '\\0x'.strToUpper(substr('0'.$hexCode,-2)).' ';}
    return $hex;}
function ArrayToXML($array) {
    $str = "";
    foreach($array as $key => $val) {
        if(gettype($array[$key]) == "array") {
            $str.= "<".$key.">";
            $str.= ArrayToXML($array[$key]);
            $str.= "</".$key.">\n";}
        else if(gettype($array[$key]) == "object") {
            $str.= "<".$key.">";
            $str.= ArrayToXML(ObjectToArray($array[$key]));
            $str.= "</".$key.">\n";}
        else if(gettype($array[$key]) == "string") {
            $str.= XML($key,$val,false);}
        else if(gettype($array[$key]) == "integer") {
            $str.= XML($key,$val,false);}
        else if(gettype($array[$key]) == "boolean") {
            $str.= XML($key,BoolToInt($val),false);}
        else {
            $str.= XML($key,$val,false);
            WriteLog("[ArrayToXML] UKNKOWN TYPE ".gettype($array[$key]));}}
    return $str;}
function ProceedInstID($inst_id,$app_id,$version) {
    global $DB;
    if($inst_id > 0 && ($rows = $DB->Select("InstallationIDs","`ID` = '".DBText($inst_id)."' AND `AppID` = '".DBText($app_id)."'",$count,"","1")) !== false && $count > 0) {
        $DB->Update("InstallationIDs","`Version` = '".DBText($version)."', `Count` = `Count` + '1', ","`ID` = '".$inst_id."'");
        return $inst_id;}
    if(IsSet($data)) { unset($data); }
    $data['AppID'] = $app_id;
    $data['Version'] = $version;
    $data['Count'] = 1;
    return $DB->Insert("InstallationIDs",$data);}
function SaveAPILogin($user_id,$inst_id,$app_id,$version,$ip) {
    if(Settings('EnableAPI')) {
        global $DB;
        if(IsSet($data)) { unset($data); }
        $data['UserID'] = $user_id;
        $data['InstID'] = $inst_id;
        $data['AppID'] = $app_id;
        $data['Version'] = $version;
        $data['IP'] = $ip;
        return $DB->Insert("APILogins",$data);}
    return false;}
function ToXML($str) {
    $str = str_replace("&","&amp;",$str);
    $str = str_replace("<","&lt;",$str);
    $str = str_replace(">","&gt;",$str);
    $str = str_replace("\n","&br;",$str);
    $str = str_replace("\"","&quot;",$str);
    return $str;}
function XML($name,$str,$wrap=true) {
    global $MTPS;
    $str = "<$name>".@iconv("utf-8",$MTPS->Charset,ToXML($str))."</$name>";
    if($wrap) { $str.= "\n"; }
    if(IsSet($_GET['html']) && $_GET['html'] == true) { $str = ToXML($str); $str = str_replace("&br;","<br />",$str); }
    return $str;}
function EchoXML($name,$str,$wrap=true) {
    echo XML($name,$str,$wrap);}
function ResultXML($resno,$str) {
    echo XML("resno",$resno);
    echo XML("result",$str);}
function CanAdmin($section="",$item_id=false,&$response="") {
    global $User, $MTPS;
    if(!IsModernBrowser()) { return false; }
    $response = "";
    $can_admin = false;
    if($User->Logged && $User->Account->AccountType > 0) {
        $acc = $User->Account;
        $type = $User->Account->AccountType;
        if($type == 1) { return true; }
        $section = mb_strtolower($section,$MTPS->Charset);
        switch($section) {
            case "administration": case "":
            if($type == 2 || $type == 3) { $can_admin = true; }
            break;
            case "edit-calendar":
                if($type == 2) { $can_admin = true; }
                break;
            case "edit-local-tv":
                if($type == 2 || $User->Account->Username == "zbynek.kratky") { $can_admin = true; }
                break;
            case "edit-sport-donations":
                if($type == 2) { $can_admin = true; }
                if($type == 3) { $can_admin = true; }
                break;
            case "delete-calendar-item":
                if($type == 2) { $can_admin = true; }
                break;
            case "edit-news":
                if($type == 2) { $can_admin = true; }
                if($type == 3 && $item_id == false) { $can_admin = true; }
                if($type == 3) { $can_admin = true; }
                break;
            case "delete-news":
                if($type == 2) { $can_admin = true; }
                break;
            case "delete-another-user":
                if($type == 2) { $can_admin = true; }
                break;
            case "edit-users-in-department":
                if($type == 2) { $can_admin = true; }
                if($type == 3 && Settings('EnableDepartments',true) && $User->UserIsMemberOfDepartmentID($User->UserID,$item_id)) { $can_admin = true; }
                break;
            case "departments":
                if($type == 2) { $can_admin = true; }
                break;
            case "buildings":
                if($type == 2) { $can_admin = true; }
                break;
            case "agendas":
                if($type == 2) { $can_admin = true; }
                break;
            case "political-parties":
                if($type == 2) { $can_admin = true; }
                break;
            case "academic-titles":
                if($type == 2) { $can_admin = true; }
                break;
            case "users-rights":
                if($type == 2) { $can_admin = true; }
                break;
            case "gallery":
                if($type == 2) { $can_admin = true; }
                break;
            case "settings":
                if($type == 2) { $can_admin = true; }
                break;
            case "pages-administration":
                if($type == 2) { $can_admin = true; }
                if($type == 3) { $can_admin = true; }
                break;
            case "pages-add-attachment":
                if($type == 2) { $can_admin = true; }
                if($type == 3) { $can_admin = true; }
                break;
            case "pages-rename-attachment":
                if($type == 2) { $can_admin = true; }
                if($type == 3) { $can_admin = true; }
                break;
            case "pages-delete-attachment":
                if($type == 2) { $can_admin = true; }
                if($type == 3) { $can_admin = true; }
                break;
            case "pages-move-attachment":
                if($type == 2) { $can_admin = true; }
                if($type == 3) { $can_admin = true; }
                break;
            case "pages-edit-text":
                if($type == 2 || $type == 3) { $can_admin = true; }
                break;
            case "rename-page":
                if($type == 2) { $can_admin = true; }
                break;
            case "pages-insert-image":
                if($type == 2 || $type == 3) { $can_admin = true; }
                break;
            case "pages-change-settings":
                if($type == 2) { $can_admin = true; }
                break;
            case "pages-delete-page":
                if($type == 2) { $can_admin = true; }
                break;
            case "pages-add-subpage":
                if($type == 2) { $can_admin = true; }
                if($type == 3) { $can_admin = true; }
                break;
            case "pages-move-subpage":
                if($type == 2) { $can_admin = true; }
                if($type == 3) { $can_admin = true; }
                break;
            case "edit-institutions":
                if($type == 2) { $can_admin = true; }
                break;
            case "downloads-add-document-by-department": case "downloads-delete-document-by-department": case "downloads-move-document-by-department": case "downloads-delete-document-by-department": case "downloads-rename-document-by-department":
            if($type == 2) { $can_admin = true; }
            if($type == 3 && Settings('EnableDepartments',true) && $User->UserIsMemberOfDepartmentID($User->UserID,$item_id)) { $can_admin = true; }
            break;
            case "edit-zmrm":
                if($type == 2) { $can_admin = true; }
                break;
            default:
                AddError("[CanAdmin] Undefined rule for $section.");
                break;}}
    if(!$can_admin) { $response = Lng('YouDontHavePermissionThisAction'); }
    return $can_admin;}
function LngPath($language="") {
    global $MTPS;
    if($language == "") { $language = $MTPS->Language; }
    if($language == $MTPS->DefaultLanguage) { return ""; }
    return $language."/";}
function UserCanAccessSection($section) {
    global $User, $MTPS;
    if($User->Logged && $User->Account->AccountType == 1) { return true; }
    $can_access = false;
    $section = mb_strtolower($section,$MTPS->Charset);
    switch($section) {
        case "administration":
            if($User->Logged && ($User->Account->AccountType == 1 || $User->Account->AccountType == 2 || $User->Account->AccountType == 3)) { $can_access = true; }
            break;
        case "delete-another-user":
            if($User->Logged && ($User->Account->AccountType == 1 || $User->Account->AccountType == 2)) { $can_access = true; }
            break;}
    return $can_access;}
function GetUserAccountID() {
    global $User;
    if(IsSet($User->Account) && $User->Account !== false && IsSet($User->Account->ID) && is_numeric($User->Account->ID) && $User->Account->ID > 0) {
        return $User->Account->ID;}
    return 0;}
function LoadSessions($web_access_id) {
    global $MTPS, $DB;
    if($web_access_id > 0) {
        $MTPS->Sessions = $DB->Select("Sessions","`WebAccessID`=".DBText($web_access_id),$MTPS->SessionsCount);}
    else {
        $MTPS->Sessions = array();}}
function SetSession($name,$value) {
    global $MTPS;
    for($aa=0; $aa<$MTPS->SessionsCount; $aa++) {
        if($MTPS->Sessions[$aa]->Name == $name) {
            $MTPS->Sessions[$aa]->Deleted = 0;
            $MTPS->Sessions[$aa]->Value = $value;
            return;}}
    $MTPS->Sessions[$MTPS->SessionsCount] = new stdClass();
    $MTPS->Sessions[$aa]->ID = 0;
    $MTPS->Sessions[$aa]->Name = $name;
    $MTPS->Sessions[$aa]->Value = $value;
    $MTPS->Sessions[$aa]->Deleted = 0;
    $MTPS->SessionsCount++;}
function GetSession($name) {
    global $MTPS;
    for($aa=0; $aa<$MTPS->SessionsCount; $aa++) {
        if($MTPS->Sessions[$aa]->Name == $name && $MTPS->Sessions[$aa]->Deleted == 0) {
            return $MTPS->Sessions[$aa]->Value;}}
    return false;}
function DeleteSession($name) {
    global $MTPS;
    for($aa=0; $aa<$MTPS->SessionsCount; $aa++) {
        if($MTPS->Sessions[$aa]->Name == $name && $MTPS->Sessions[$aa]->Deleted == 0) {
            $MTPS->Sessions[$aa]->Deleted = Time();
            return true;}}
    return false;}
function SaveSessions() {
    global $MTPS, $DB;
    if($MTPS->WebAccessID == 0) { return; }
    for($aa=0; $aa<$MTPS->SessionsCount; $aa++) {
        if($MTPS->Sessions[$aa]->Deleted == 0) {
            $DB->Delete("Sessions","`ID` = '".DBText($MTPS->Sessions[$aa]->ID)."'");
            if($MTPS->Sessions[$aa]->Name != "") {
                if(IsSet($data)) { unset($data); }
                $data['Name'] = $MTPS->Sessions[$aa]->Name;
                $data['Value'] = $MTPS->Sessions[$aa]->Value;
                if($MTPS->SaveWebAccess) {
                    $data['WebAccessID'] = $MTPS->WebAccessID;}
                $MTPS->Sessions[$aa]->ID = $DB->Insert("Sessions",$data);}}
        else {
            if($MTPS->Sessions[$aa]->ID > 0) {
                $DB->Delete("Sessions","`ID` = '".DBText($MTPS->Sessions[$aa]->ID)."'");}}}}
function WritePhoneNumber($number) {
    $str = "";
    if(strlen($number) == 12) {
        $str.= "+";
        $str.= $number[0];
        $str.= $number[1];
        $str.= $number[2];
        $str.= chr(32);
        $str.= $number[3];
        $str.= $number[4];
        $str.= $number[5];
        $str.= chr(32);
        $str.= $number[6];
        $str.= $number[7];
        $str.= $number[8];
        $str.= chr(32);
        $str.= $number[9];
        $str.= $number[10];
        $str.= $number[11];}
    else {
        $str = $number;}
    return $str;}
function IsPageNameAllowedChar($char) {
    $list = "abcdefghijklmnopqrstuvwxyz-0123456789";
    for($aa=0; $aa<strlen($list); $aa++) {
        if($char == $list[$aa]) { return true; }}
    return false;}
function PageNameToDirName($name) {
    global $MTPS;
    $name = RemoveDiacritic($name);
    $name = mb_strtolower($name,$MTPS->Charset);
    $name = trim($name);
    $new_name = (string)"";
    for($aa=0; $aa<strlen($name); $aa++) {
        if(IsPageNameAllowedChar($name[$aa])) {
            $new_name.= $name[$aa];}
        else {
            $new_name.= "-";}}
    while(strpos($new_name,"--",0) !== false) { $new_name = str_replace("--","-",$new_name); }
    if($new_name[0] == "-") { $new_name[0] = chr(32); }
    if($new_name[strlen($new_name)-1] == "-") { $new_name[strlen($new_name)-1] = 0; }
    $new_name = trim($new_name);
    return $new_name;}
function AdminSectionTitle($section,$aditional_title="",$back_url="",$form_save="") {
    global $MTPS;
    $str = "";
    $str.= "<div class=\"title\">";
    $str.= "<h1>";
    if($aditional_title != "") {
        if(is_numeric($aditional_title)) {
            $str.= Lng($section);
            $str.= "<span style=\"font-size: 85%; font-weight: normal; \"> [$aditional_title]</span>";}
        else {
            $str.= Lng($section)."&nbsp;".$aditional_title;}}
    else {
        $str.= Lng($section);}
    $str.= "</h1>";
    switch($section) {
        case 'News':
            $str.= "<a href=\"".$GLOBALS['urlADMIN'].Lng('urlNEWS')."/".Lng('urlADD')."/\"><img src=\"".$GLOBALS['urlIMG']."icon/add.png\" alt=\"\" />".Lng('NewNews')."</a>";
            break;
        case 'Users':
            $str.= "<a href=\"".$GLOBALS['urlUSERS_ADMIN'].Lng('urlADD')."/\"><img src=\"".$GLOBALS['urlIMG']."icon/add.png\" alt=\"\" />".Lng('NewUser')."</a>";
            break;
        case 'Agendas':
            $str.= "<a href=\"".$GLOBALS['urlUSERS_ADMIN'].Lng('urlAGENDAS')."/".Lng('urlADD')."/\"><img src=\"".$GLOBALS['urlIMG']."icon/add.png\" alt=\"\" />".Lng('NewAgenda')."</a>";
            break;
        case 'Departments':
            $str.= "<a href=\"".$GLOBALS['urlUSERS_ADMIN'].Lng('urlDEPARTMENTS')."/".Lng('urlADD')."/\"><img src=\"".$GLOBALS['urlIMG']."icon/add.png\" alt=\"\" />".Lng('NewDepartment')."</a>";
            break;
        case 'Buildings':
            $str.= "<a href=\"".$GLOBALS['urlUSERS_ADMIN'].Lng('urlBUILDINGS')."/".Lng('urlADD')."/\"><img src=\"".$GLOBALS['urlIMG']."icon/add.png\" alt=\"\" />".Lng('NewBuilding')."</a>";
            break;
        case 'PoliticalParties':
            $str.= "<a href=\"".$GLOBALS['urlUSERS_ADMIN'].Lng('urlPOLITICALPARTIES')."/".Lng('urlADD')."/\"><img src=\"".$GLOBALS['urlIMG']."icon/add.png\" alt=\"\" />".Lng('NewPoliticalParty')."</a>";
            break;
        case 'AcademicTitles':
            $str.= "<a href=\"".$GLOBALS['urlUSERS_ADMIN'].Lng('urlACADEMICTITLES')."/".Lng('urlADD')."/\"><img src=\"".$GLOBALS['urlIMG']."icon/add.png\" alt=\"\" />".Lng('NewAcademicTitle')."</a>";
            break;
        case 'UsersRights':
            $str.= "<a href=\"".$GLOBALS['urlUSERS_ADMIN'].Lng('urlRIGHTS')."/".Lng('urlADD')."/\"><img src=\"".$GLOBALS['urlIMG']."icon/add.png\" alt=\"\" />".Lng('NewUsersRight')."</a>";
            break;}
    $text = Lng('DoYouReallyWant').chr(32).Lng('ToLeaveWithoutSavingChanges')."?";
    $text = str_replace("\"","&quot;",$text);
    if($back_url != "") { $str.= "<a href=\"$back_url\" onclick=\"Dialog_YesCancel(0,'".Lng('Back')."','".$text."','".$back_url."'); return false;\"><img src=\"".$GLOBALS['urlIMG']."icon/back.png\" alt=\"\" />".Lng('Back')."</a>"; }
    if($form_save != "") { $str.= "<a href=\"#\" onclick=\"document.forms['".$form_save."'].submit(); return false;\"><img src=\"".$GLOBALS['urlIMG']."icon/accept.png\" alt=\"\" />".Lng('Save')."</a>"; }
    $str.= "</div><div class=\"clear\"></div>";
    return $str;}
function ArrayToObject($array) {
    $obj = new stdClass();
    if(is_array($array)) {
        $obj = new StdClass();
        foreach($array as $key => $val){
            $obj->$key = $val;}}
    else {
        $obj = $array;}
    return $obj;}
function ObjectToArray($object,$prefix="") {
    $array = array();
    if(is_object($object)) {
        foreach($object as $key => $value) {
            $array[$prefix.$key] = $value;}}
    else {
        $array = $object;}
    return $array;}
function IsModernBrowser() {
    global $MTPS;
    $name = mb_strtolower($MTPS->BrowserName,$MTPS->Charset);
    if($name == "internet explorer" && $MTPS->BrowserVersion <= 9) { return false; }
    return true;}
function UserHasToBeLoggedIn($section) {
    global $MTPS;
    $section = mb_strtolower($section,$MTPS->Charset);
    return false;}
function ModuleEnabled($module) {
    global $MODULES, $MTPS;
    $module = strtolower($module);
    if(IsSet($MODULES[$module])) {
        return $MODULES[$module]->Enabled;}
    return false;}
function ClassByTwo($path_two) {
    global $MTPS;
    if($MTPS->PathTwo == $path_two) { return "active"; }
    if($MTPS->PathOne == "admin") {
        if($path_two == "" && $MTPS->PathTwo == Lng('urlUSERS')) {
            if($MTPS->PathTwo == Lng('urlADD') || $MTPS->PathTwo == Lng('urlEDIT')) { return "active"; }}}
    return "";}
function ClassByThree($path_three) {
    global $MTPS;
    if($MTPS->PathThree == $path_three) { return "active"; }
    if($MTPS->PathOne == "admin") {
        if($path_three == "" && ($MTPS->PathTwo == Lng('urlUSERS') || $MTPS->PathTwo == Lng('urlOFICIALBOARD') || $MTPS->PathTwo == Lng('urlNEWS'))) {
            if($MTPS->PathThree == Lng('urlADD') || $MTPS->PathThree == Lng('urlEDIT')) { return "active"; }}}
    return "";}
function IsWebSection($section) {
    global $MTPS;
    if(mb_strtolower($GLOBALS['Web']->Section,$MTPS->Charset) == mb_strtolower($section,$MTPS->Charset)) { return true; }
    return false;}
function UserCanCreateNewAccount() {
    global $MTPS, $User;
    if($MTPS->OnlyAdminCanCreateNewAccount) {
        if($User->Logged && $User->Account->Type == 1) {
            return true;}
        else {
            return false;}}
    return true;}
function GetWebLanguages(&$languages) {
    $count = 0;
    $languages = array();
    $languages[$count] = new stdClass(); $languages[$count]->Language = "cs"; $count++;
    $languages[$count] = new stdClass(); $languages[$count]->Language = "en"; $count++;
    return $count;}
function MyIP() {
    if(IsSet($_SERVER['REMOTE_ADDR'])) { return $_SERVER['REMOTE_ADDR']; }
    return "0.0.0.0";}
function ClearURL($url) {
    $getstr = "";
    if(IsSet($_POST['SendFormName'])) { return; }
    $pos = strpos($url,"?",0);
    if($pos !== false) {
        $getstr = utf8_substr($url,$pos);
        $urlstr = utf8_substr($url,0,$pos);}
    else {
        $urlstr = $url;}
    $len = strlen($urlstr);
    if(($pos = strpos($urlstr,".php",$len-5)) !== false) {
        $urlstr = utf8_substr($urlstr,0,$len-4);}
    if($urlstr.$getstr != $url) {
        Header("Location: ".$urlstr.$getstr);
        exit();}}
function WriteCharsetHeader() {
    global $MTPS;
    if(!$MTPS->CharsetHeaderWritten) {
        $MTPS->CharsetHeaderWritten = true;
        Header('Content-Type: text/html; charset='.$MTPS->Charset,'',$MTPS->HttpResponseCode);
        Header('Expires: '.gmdate('D, d M Y H:i:s \G\M\T',time()+(60*60)));}}
function DoExit($write_reports=false) {
    global $DB;
    if($write_reports) {
        WriteCharsetHeader();
        echo WriteReports();}
    SaveSessions();
    if(IsSet($GLOBALS['DB'])) { $GLOBALS['DB']->Disconnect(); }
    exit();}
function XSS($str) {
    return htmlspecialchars($str);}

    
function SendEmail($send_now,$priority,$recipient_email,$recipient_name,$subject,$content_html,$use_sign=true,$attachments="",$from_smtp=0,$reply_to_email="",$reply_to_name="") {

    global $MTPS, $DB;
    if(IsSet($data)) { unset($data); }
    $data['Priority'] = $priority;
    $data['RecipientEmail'] = $recipient_email;
    $data['RecipientName'] = $recipient_name;
    $data['Subject'] = $subject;
    $content_sign = "";
    if($use_sign) {
        if(IsSet($MTPS->EmailSign[$MTPS->Language])) { $content_sign = $MTPS->EmailSign[$MTPS->Language]; }
        else {
            if(IsSet($MTPS->EmailSign[$MTPS->DefaultLanguage]))
            { $content_sign = $MTPS->EmailSign[$MTPS->DefaultLanguage];
            }
        }
    }
    $new_content_html = str_replace("%EmailBody%","<p>".$content_html."</p>".$content_sign."<p style=\"margin: 0; padding: 1em 0 0 0; color: gray;\">".Lng('ThisMessageWasSentToEmailAddress',$recipient_email)."</p>",$MTPS->EmailBody);
    $data['ContentHTML'] = $new_content_html;
    $data['Attachments'] = $attachments;
    $data['FromSMTP'] = $from_smtp;
    $data['ReplyToEmail'] = $reply_to_email;
    $data['ReplyToName'] = $reply_to_name;
    $email_id = $DB->Insert("Emails",$data);
    if($email_id && $send_now) {
        SendEmailNow($email_id,$priority,$recipient_email,$recipient_name,$subject,$new_content_html,$attachments,$from_smtp,$reply_to_email,$reply_to_name);}
    return $email_id;}



function SendEmailNow($email_id,$priority,$recipient_email,$recipient_name,$subject,$content_html,$attachments="",$from_smtp=0,$reply_to_email="",$reply_to_name="") {
    global $MTPS, $DB;
    $note = "";
    $result = 0;
    $mail = new PHPMailer(true);
    $mail->IsSMTP();
    try {
        $mail->SMTPDebug = false;
        $mail->CharSet = $MTPS->Charset;
        $mail->Priority = $priority;
        $mail->AddAddress($recipient_email,$recipient_name);
        $mail->Subject = $subject;
        $mail->AltBody = "";
        $mail->MsgHTML($content_html);
        if($reply_to_email != "") {
            $mail->AddReplyTo($reply_to_email,$reply_to_name);}
        if($attachments != "") {
            foreach(explode(';',$attachments) as $attpos => $attval) {
                $mail->AddAttachment($attval);}}
        if($from_smtp <= 0) {
            $mail->Host = $MTPS->EmailHost;
            $mail->Port = $MTPS->EmailPort;
            $mail->SMTPAuth = $MTPS->EmailSMTPAuth;
            $mail->Username = $MTPS->EmailUsername;
            $mail->Password = $MTPS->EmailPassword;
            $mtps_from_email = $MTPS->EmailFromEmail;
            if(IsSet($MTPS->EmailFromEmailRandomize) && $MTPS->EmailFromEmailRandomize == true) {
                $mtps_from_email = CreateRandomHash(7).".".CreateRandomHash(9).$MTPS->EmailFromEmail;}
            $mail->SetFrom($mtps_from_email,$MTPS->EmailFromName);}
        else {
            if($smtp_rows = $DB->Select("SMTP","`ID` = '".DBText($from_smtp)."'",$smtp_count)) {
                if($smtp_count > 0) {
                    $mail->SMTPAuth = true;
                    $mail->Host = $smtp_rows[0]->Host;
                    $mail->Port = $smtp_rows[0]->Port;
                    if($mail->Port == 587) {
                        $mail->SMTPSecure = 'tls';}
                    else {
                        $mail->SMTPSecure = 'ssl';}
                    if($smtp_rows[0]->Username == "") { $mail->SMTPAuth = false; } else { $mail->SMTPAuth = true; }
                    $mail->Username = $smtp_rows[0]->Username;
                    $mail->Password = $smtp_rows[0]->Password;
                    $mail->SetFrom($smtp_rows[0]->FromEmail,$smtp_rows[0]->FromName);}
                else {
                    $note.= "[SendEmailNow] smtp_count = 0!";}}}
        $mail->Send();
        $result = 1;}
    catch(phpmailerException $e) {
        $result = 2;
        $note.= $e->errorMessage();}
    catch(Exception $e) {
        $result = 3;
        if($note != "") { $note.= "\n"; }
        $note.= $e->getMessage();}
    $set = "`SentResult` = '$result', ";
    $set.= "`SentTime` = '".Time()."', ";
    $set.= "`Note` = '".DBText($note)."', ";
    $DB->Update("Emails",$set,"`ID` = '".DBText($email_id)."'");}
function SaveWebLoadStatistics($http_response_code,$ip,$date,$hour,$minute,$protocol,$host,$path,$get,$layout,$language,$browser_name,$browser_version,$user_agent,$referer,$web_access_id=0,$user_id=0,$page_id=0) {
    if($path == "pim/mtps2/img/transparent.gif" || $path == "pim/img/transparent.gif") { return false; }
    global $MTPS, $DB;
    if(IsSet($data)) { unset($data); }
    $data['HttpResponseCode'] = $http_response_code;
    $data['IP'] = $ip;
    $data['Date'] = $date;
    $data['Hour'] = $hour;
    $data['Minute'] = $minute;
    $data['Protocol'] = $protocol;
    $data['Host'] = $host;
    $data['Path'] = $path;
    $data['Get'] = $get;
    $data['Layout'] = $layout;
    $data['Language'] = $language;
    $data['BrowserName'] = $browser_name;
    $data['BrowserVersion'] = $browser_version;
    $data['UserAgent'] = $user_agent;
    $data['Referer'] = $referer;
    if($MTPS->SaveWebAccess) {
        $data['WebAccessID'] = $web_access_id;}
    $data['UserID'] = $user_id;
    $data['PageID'] = $page_id;
    return $DB->Insert("StatsPages",$data);}
function GetWebLoadStatistics($path,&$access_count,&$unique_count,&$users_unique_count) {
    global $DB, $MTPS;
    $where = "`Date` = '".DBText($MTPS->Date)."' AND `Path` = '".DBText($path)."'";
    $rows = $DB->Select("StatsPages",$where,$access_count);
    $where = "`Date` = '".DBText($MTPS->Date)."' AND `Path` = '".DBText($path)."'";
    if($MTPS->SaveWebAccess) {
        $rows = $DB->Select("StatsPages",$where,$unique_count,"","","`WebAccessID`");}
    else {
        $rows = $DB->Select("StatsPages",$where,$unique_count,"","","");}
    $where = "`Date` = '".DBText($MTPS->Date)."' AND `UserID` != '0' AND `Path` = '".DBText($path)."'";
    $rows = $DB->Select("StatsPages",$where,$users_unique_count,"","","`UserID`");}
function DBText($str) {
    return mysqli_real_escape_string($GLOBALS['DB']->Connection,$str);}
function RealGetToString() {
    $str = "";
    foreach($_GET as $param => $value) {
        if(strlen($str) > 0) { $str.= "&"; }
        $str.= $param."=".$value;}
    return $str;}
function AddSuccess($text,$write_log=false) {
    return AddReport($text,1,$write_log);}
function AddError($text,$write_log=false) {
    return AddReport($text,2,$write_log);}
function AddErrorAndReload($text,$url) {
    AddError($text);
    $_POST['GoTo'] = $url; $_POST['GoToReload'] = $url; LinkReload($GLOBALS['urlMTPS']);}
function AddReport($text,$type=0,$write_log=false) {
    if($text !== false && $text != "") {
        for($aa=0; $aa<$GLOBALS['REPORT_COUNT']; $aa++) {
            if($GLOBALS['REPORT_TEXT'][$aa] == $text && $GLOBALS['REPORT_TYPE'][$aa] == $type) { return $text; }}
        $GLOBALS['REPORT_TEXT'][$GLOBALS['REPORT_COUNT']] = $text;
        $GLOBALS['REPORT_TYPE'][$GLOBALS['REPORT_COUNT']] = $type;
        $GLOBALS['REPORT_COUNT']++;}
    if($write_log) { WriteLog($text); }
    return $text;}
function WriteReports() {
    $str = "";
    if($GLOBALS['REPORT_COUNT'] > 0) {
        for($aa=0; $aa<$GLOBALS['REPORT_COUNT']; $aa++) {
            $class = "Report";
            if($GLOBALS['REPORT_TYPE'][$aa] == 1) { $class = "SuccessReport"; }
            if($GLOBALS['REPORT_TYPE'][$aa] == 2) { $class = "ErrorReport"; }
            $str.= '<div class="'.$class.'">';
            $str.= iconv("utf-8",$GLOBALS['MTPS']->Charset,$GLOBALS['REPORT_TEXT'][$aa]);
            $str.= '</div>'; $str.= "\n";}}
    $GLOBALS['REPORT_COUNT'] = 0;
    $GLOBALS['REPORT_TEXT'] = "";
    $GLOBALS['REPORT_TYPE'] = "";
    return $str;}
function WriteReportsText() {
    $str = "";
    if($GLOBALS['REPORT_COUNT'] > 0) {
        for($aa=0; $aa<$GLOBALS['REPORT_COUNT']; $aa++) {
            $str.= iconv("utf-8",$GLOBALS['MTPS']->Charset,str_replace("<br />","\n",$GLOBALS['REPORT_TEXT'][$aa])."\n");}}
    $GLOBALS['REPORT_COUNT'] = 0;
    $GLOBALS['REPORT_TEXT'] = "";
    $GLOBALS['REPORT_TYPE'] = "";
    return $str;}
function ActionLinkReload($copy_post=true) {
    if(IsSet($_REQUEST['ActionLink']) && !Empty($_REQUEST['ActionLink'])) { $action_link = urldecode($_REQUEST['ActionLink']); }
    if(!IsSet($action_link) && IsSet($_GET['ActionLink'])) { $action_link = $_GET['ActionLink']; }
    if(!IsSet($action_link) && IsSet($_POST['ActionLink'])) { $action_link = $_POST['ActionLink']; }
    if(!IsSet($action_link)) { if(IsSet($GLOBALS['URL'])) { $action_link = $GLOBALS['URL']; } }
    if(IsSet($action_link)) {
        ReportToSession();
        if($copy_post) { PostToSession(); }
        Header("Location: ".CreateLink($action_link,"","",true));
        DoExit();}}
function LinkReload($action_link,$copy_post=true) {
    if(IsSet($action_link)) {
        ReportToSession();
        if($copy_post) { PostToSession(); }
        Header("Location: ".$action_link);
        DoExit();}}
function PostToSession() {
    if(IsSet($_POST) && (IsSet($_POST['SendFormName']) || IsSet($_POST['GoTo']))) {
        $count = 0;
        foreach($_POST as $key => $value) {
            if($key) {
                if($key == "SendFormName") {
                    $key = "_SendFormName";
                    unset($_POST['SendFormName']);}
                $_name = '_postName'.$count;
                $_val = '_postVal'.$count;
                SetSession($_name,$key);
                SetSession($_val,$value);
                $count++;}}
        SetSession('_postCount',$count);}}
function SessionToPost() {
    $count = GetSession('_postCount');
    if(IsSet($_POST) && !IsSet($_POST['SendFormName']) && $count !== false) {
        for($aa=0; $aa<$count; $aa++) {
            $_name = '_postName'.$aa;
            $_val = '_postVal'.$aa;
            $key = GetSession($_name);
            if($key !== false && $key != "") {
                $val = GetSession($_val);
                if($val !== false) {
                    $_POST[$key] = $val;}}
            DeleteSession($_name);
            DeleteSession($_val);}
        DeleteSession('_postCount');}}
function ReportToSession() {
    if($GLOBALS['REPORT_COUNT'] > 0) {
        SetSession('ReportCount',$GLOBALS['REPORT_COUNT']);
        for($aa=0; $aa<$GLOBALS['REPORT_COUNT']; $aa++) {
            $name_type = 'ReportType'.$aa;
            $name_text = 'ReportText'.$aa;
            SetSession($name_type,$GLOBALS['REPORT_TYPE'][$aa]);
            SetSession($name_text,$GLOBALS['REPORT_TEXT'][$aa]);}}
    $GLOBALS['REPORT_COUNT'] = 0;
    $GLOBALS['REPORT_TEXT'] = "";
    $GLOBALS['REPORT_TYPE'] = "";}
function SessionToReport() {
    $count = GetSession('ReportCount');
    if($count !== false && $count > 0) {
        for($aa=0; $aa<$count; $aa++) {
            $name_type = 'ReportType'.$aa;
            $name_text = 'ReportText'.$aa;
            $type = GetSession($name_type);
            $text = GetSession($name_text);
            if($type !== false && $text !== false) {
                AddReport($text,$type);
                DeleteSession($name_text);
                DeleteSession($name_type);}}
        DeleteSession('ReportCount');}}
function GetFilePath($file,&$filename,&$path) {
    $pos = 0;
    $lastpos = 0;
    $ext = "";
    while(($pos = strpos($file,".",$lastpos)) !== false) {
        $lastpos = $pos+1;
        $ext = substr($file,$lastpos);}
    $filename = substr($file,0,$lastpos-1);
    $pos = 0;
    $lastpos = 0;
    while(($pos = strpos($filename,"/",$lastpos)) !== false) {
        $lastpos = $pos+1;}
    $path = substr($filename,0,$lastpos);
    $filename = substr($filename,$lastpos);
    return $ext;}
function GetFileExtension($file,&$filename) {
    $pos = 0;
    $lastpos = 0;
    $ext = "";
    while(($pos = strpos($file,".",$lastpos)) !== false) {
        $lastpos = $pos+1;
        $ext = substr($file,$lastpos);}
    $filename = substr($file,0,$lastpos-1);
    $pos = 0;
    $lastpos = 0;
    while(($pos = strpos($filename,"/",$lastpos)) !== false) {
        $lastpos = $pos+1;}
    $filename = substr($filename,$lastpos);
    return $ext;}
function HasExtension($file) {
    $ext = GetFileExtension($file,$filename);
    if($ext != "") { return true; }
    return false;}
function GetLastNumericPartFromString($string,&$before_part) {
    $pos = 0;
    $len = strlen($string);
    for($aa=0; $aa<$len; $aa++) {
        if(ord($string[$len-$aa-1]) < 48 || ord($string[$len-$aa-1]) > 57) { $pos = $len-$aa; break; }}
    $before_part = substr($string,0,$pos);
    $number = substr($string,$pos);
    return $number;}
function CreateRandomHash($CharCount=10) {
    $chars = 'abcdefghjkmnpqrstuvwxyz23456789';
    $pass = '';
    for($aa=0; $aa<$CharCount; $aa++) {
        $pass.= SubStr($chars,Rand(0,StrLen($chars)-1),1);}
    return $pass;}
function CreatePassword($CharCount=10) {
    $chars = 'abcdefghjkmnpqrstuvwxyz23456789';
    $pass = '';
    for($aa=0; $aa<$CharCount; $aa++) {
        $pass.= SubStr($chars,Rand(0,StrLen($chars)-1),1);}
    return $pass;}
function SaveWebAccess() {
    global $MTPS, $DB;
    if(IsSet($_COOKIE['WebAccessID']) && IsSet($_COOKIE['WebAccessHash']) && $DB->Update("WebAccess","`Count`=`Count`+1, ","`ID`=".DBText($_COOKIE['WebAccessID'])." AND `Hash` = '".DBText($_COOKIE['WebAccessHash'])."'")) {
/*        SetCookie("WebAccessID",$_COOKIE['WebAccessID'],Time()+90*24*60*60,'/; SameSite=strict','',false,true);*/

        SetCookie("WebAccessID",$_COOKIE['WebAccessID'],
        [
            'expires' => Time()+90*24*60*60,
            'path' => '/',
            'domain' => '',
            'secure' => true,
            'httponly' => true,
            'samesite' =>'strict',
        ]);

/*        SetCookie("WebAccessHash",$_COOKIE['WebAccessHash'],Time()+90*24*60*60,'/; samesite=strict','',false,true);*/

        SetCookie("WebAccessHash",$_COOKIE['WebAccessHash'],        [
            'expires' => Time()+90*24*60*60,
            'path' => '/',
            'domain' => '',
            'secure' => true,
            'httponly' => true,
            'samesite' =>'strict',
        ]);
        $MTPS->WebAccessID = $_COOKIE['WebAccessID'];}
    else {
        $web_access_hash = CreatePassword(8);
        if(IsSet($data)) { unset($data); }
        $data['Hash'] = $web_access_hash;
        $MTPS->WebAccessID = $DB->Insert("WebAccess",$data);
        SetCookie("WebAccessID",$MTPS->WebAccessID,Time()+90*24*60*60,'/; samesite=strict','',false,true);
        SetCookie("WebAccessHash",$web_access_hash,Time()+90*24*60*60,'/; samesite=strict','',false,true);}}
function GetUserAgent() {
    if(isset($_SERVER["HTTP_USER_AGENT"]) && ($_SERVER["HTTP_USER_AGENT"] != "")) {
        return $_SERVER["HTTP_USER_AGENT"];}
    return "Unknown";}
function GetBrowser() {
    $visitor_user_agent = GetUserAgent();
    $pattern = "";
    $bname = 'Unknown';
    $version = "0.0.0";
    $major_version = -1;
    if(preg_match("/MSIE/i",$visitor_user_agent) && !preg_match("/Opera/i",$visitor_user_agent)) {
        $bname = 'Internet Explorer';
        $ub = "MSIE";
    } elseif(preg_match("/Firefox/i",$visitor_user_agent)) {
        $bname = 'Mozilla Firefox';
        $ub = "Firefox";
    } elseif(preg_match("/Chrome/i",$visitor_user_agent)) {
        $bname = 'Google Chrome';
        $ub = "Chrome";
    } elseif(preg_match("/Safari/i",$visitor_user_agent)) {
        $bname = 'Apple Safari';
        $ub = "Safari";
    } elseif(preg_match("/Opera/i",$visitor_user_agent)) {
        $bname = 'Opera';
        $ub = "Opera";
    } elseif(preg_match("/Netscape/i",$visitor_user_agent)) {
        $bname = 'Netscape';
        $ub = "Netscape";
    } elseif(preg_match("/Seamonkey/i",$visitor_user_agent)) {
        $bname = 'Seamonkey';
        $ub = "Seamonkey";
    } elseif(preg_match("/Konqueror/i",$visitor_user_agent)) {
        $bname = 'Konqueror';
        $ub = "Konqueror";
    } elseif(preg_match("/Navigator/i",$visitor_user_agent)) {
        $bname = 'Navigator';
        $ub = "Navigator";
    } elseif(preg_match("/Mosaic/i",$visitor_user_agent)) {
        $bname = 'Mosaic';
        $ub = "Mosaic";
    } elseif(preg_match("/Lynx/i",$visitor_user_agent)) {
        $bname = 'Lynx';
        $ub = "Lynx";
    } elseif(preg_match("/Amaya/i",$visitor_user_agent)) {
        $bname = 'Amaya';
        $ub = "Amaya";
    } elseif(preg_match("/Omniweb/i",$visitor_user_agent)) {
        $bname = 'Omniweb';
        $ub = "Omniweb";
    } elseif(preg_match("/Avant/i",$visitor_user_agent)) {
        $bname = 'Avant';
        $ub = "Avant";
    } elseif(preg_match("/Camino/i",$visitor_user_agent)) {
        $bname = 'Camino';
        $ub = "Camino";
    } elseif(preg_match("/Flock/i",$visitor_user_agent)) {
        $bname = 'Flock';
        $ub = "Flock";
    } elseif(preg_match("/AOL/i",$visitor_user_agent)) {
        $bname = 'AOL';
        $ub = "AOL";
    } elseif(preg_match("/AIR/i",$visitor_user_agent)) {
        $bname = 'AIR';
        $ub = "AIR";
    } elseif(preg_match("/Fluid/i",$visitor_user_agent)) {
        $bname = 'Fluid';
        $ub = "Fluid";
    } else {
        if(strpos($visitor_user_agent,'Trident/7.0; rv:11.0') !== false) {
            $bname = 'Internet Explorer';
            $ub = "MSIE";
            $major_version = 11;}
        else {
            $bname = 'Unknown';
            $ub = "Unknown";}}
    if($major_version == -1) {
        $known = array('Version', $ub, 'other');
        $pattern = '#(?<browser>' . join('|', $known) .
            ')[/ ]+(?<version>[0-9.|a-zA-Z.]*)#';
        if(!preg_match_all($pattern, $visitor_user_agent, $matches)) {}
        $i = count($matches['browser']);
        if($i != 1) {
            if(strripos($visitor_user_agent, "Version") < strripos($visitor_user_agent, $ub)) {
                if(IsSet($matches['version'][0])) { $version = $matches['version'][0]; }
            } else {
                if(IsSet($matches['version'][1])) { $version = $matches['version'][1]; }}
        } else {
            if(IsSet($matches['version'][0])) { $version = $matches['version'][0]; }}
        if($version == null || $version == "") {
            $version = "?";}
        $major_version = 0;
        $pos = strpos($version,".");
        if($pos !== false) {
            $major_version = substr($version,0,$pos);}}
    return array(
        'userAgent' => $visitor_user_agent,
        'name' => $bname,
        'version' => $version,
        'major_version' => $major_version,
        'pattern' => $pattern);}
function trm($str) {
    return trim($str)."\n";}
function AddNavigation($caption,$url) {
    global $Web;
    if(IsSet($Web->Part['Navigation']) && $Web->Part['Navigation'] != "") {
        $Web->AddPart("Navigation","	&#32;<span>&gt;</span>&nbsp;");}
    $Web->AddPart("Navigation","<a href=\"$url\">$caption</a>");
    $GLOBALS['NavigationLastURL'] = AddSlashToEnd($url);}
function Price($price,$currency="Kč") {
    return number_format(round(($price/100),1), 2, ',', ' ').chr(32).$currency;}
function MultiPrice($price,$count,$sale_per_piece) {
    $total_price = $price;
    if($count > 1) {
        for($aa=0; $aa<$count-1; $aa++) {
            $price*= ((100-$sale_per_piece)/100);
            $total_price+= $price;}}
    $total_price = round(($total_price/100),0)*100;
    return $total_price;}
function YesNo($value) {
    if($value) { return Lng('Yes'); }
    return Lng('No');}
function LngStr($string_json,$language="",$htmlspecialchars=true) {
    global $MTPS;
    if($language == "") { $language = $MTPS->Language; }
    $strings = json_decode($string_json,true);
    if(is_array($strings)) {
        if(IsSet($strings[$language]) && $strings[$language] != "") {
            if($htmlspecialchars) { return htmlspecialchars($strings[$language]); }
            return $strings[$language];}
        else if(IsSet($strings[$MTPS->DefaultLanguage]) && $strings[$MTPS->DefaultLanguage] != "") {
            if($htmlspecialchars) { return htmlspecialchars($strings[$MTPS->DefaultLanguage]); }
            return $strings[$MTPS->DefaultLanguage];}
        else {
            return "";}}
    if($htmlspecialchars) { return htmlspecialchars($string_json); }
    return $string_json;}
function LngStr2($string_json,$language,$htmlspecialchars=true) {
    global $MTPS;
    $strings = json_decode($string_json,true);
    if(is_array($strings)) {
        if(IsSet($strings[$language]) && $strings[$language] != "") {
            if($htmlspecialchars) { return htmlspecialchars($strings[$language]); }
            return $strings[$language];}}
    return "";}
function Settings($setting,$value=true) {
    global $MTPS;
    if(IsSet($MTPS->Settings[$setting])) {
        if($MTPS->Settings[$setting] == $value) { return true; }}
    return false;}
function SettingsStr($setting) {
    global $MTPS;
    if(IsSet($MTPS->Settings[$setting])) {
        return $MTPS->Settings[$setting];}
    return "";}
function LoadAssigns($first_item_name,$first_item_id,$table_name,&$count) {
    global $DB;
    $count = 0;
    if($first_item_name == "" || $first_item_id <= 0 || $table_name == "") { return false; }
    $where = "`".DBText($first_item_name)."` = '".DBText($first_item_id)."'";
    if(($rows = $DB->Select($table_name,$where,$count)) !== false && $count > 0) {
        return $rows;}
    return false;}
function RemoveDiacritic($text) {
    $table = Array(
        'ä'=>'a',
        'Ä'=>'A',
        'á'=>'a',
        'Á'=>'A',
        'č'=>'c',
        'Č'=>'C',
        'ć'=>'c',
        'Ć'=>'C',
        'ď'=>'d',
        'Ď'=>'D',
        'ě'=>'e',
        'Ě'=>'E',
        'é'=>'e',
        'É'=>'E',
        'ë'=>'e',
        'Ë'=>'E',
        'í'=>'i',
        'Í'=>'I',
        'ľ'=>'l',
        'Ľ'=>'L',
        'ń'=>'n',
        'Ń'=>'N',
        'ň'=>'n',
        'Ň'=>'N',
        'ó'=>'o',
        'Ó'=>'O',
        'ö'=>'o',
        'Ö'=>'O',
        'ř'=>'r',
        'Ř'=>'R',
        'ŕ'=>'r',
        'Ŕ'=>'R',
        'š'=>'s',
        'Š'=>'S',
        'ś'=>'s',
        'Ś'=>'S',
        'ť'=>'t',
        'Ť'=>'T',
        'ú'=>'u',
        'ů'=>'u',
        'Ú'=>'U',
        'Ů'=>'U',
        'ü'=>'u',
        'Ü'=>'U',
        'ý'=>'y',
        'Ý'=>'Y',
        'ž'=>'z',
        'Ž'=>'Z',
        'ź'=>'z',
        'Ź'=>'Z');
    return strtr($text,$table);}
function MTPS_LoadSpecialFile($file) {
    global $fileMTPS;
    return file_get_contents($fileMTPS.$file);}
function BoolToStr($value) {
    if($value) { return "true"; }
    return "false";}
function BoolToInt($value) {
    if($value) { return 1; }
    return 0;}
function IntToYN($value) {
    if($value) { return "Y"; }
    return "N";}
function ArrayToJsStr($arr) {
    $str = "new Array(";
    $count = 0;
    foreach($arr as $key => $val) {
        if($count > 0) { $str.= ","; }
        $str.= "\"".$val."\"";
        $count++;}
    $str.= ")";
    return $str;}
function DeleteBetween(&$buf,$first,$second,&$text="") {
    $deleted = false;
    $dl = strlen($first);
    if(($pos = strpos($buf,$first,0)) !== false) {
        if(($pos2 = strpos($buf,$second,$pos+$dl)) !== false) {
            $text = substr($buf,0,$pos);
            $text.= substr($buf,$pos2+strlen($second));
            $deleted = true;}}
    return $deleted;}
function WriteFullNameWithAcademicTitles($academic_titles,$first_name,$last_name) {
    global $DB;
    $str = "";
    if(Settings('EnableAcademicTitles',true)) {
        $atitles_arr = explode(";",$academic_titles);
        $where = "";
        for($aa=0; $aa<4; $aa++) {
            if(IsSet($atitles_arr[$aa]) && $atitles_arr[$aa] > 0) {
                if($aa > 0) { $where.= " OR "; }
                $where.= "`ID` = '".DBText($atitles_arr[$aa])."'";}}
        if($where != "") {
            if(($rows = $DB->Select("AcademicTitles",$where,$count)) !== false && $count > 0) {
                for($aa=0; $aa<$count; $aa++) {
                    if($rows[$aa]->Type == 1) { $str.= $rows[$aa]->Shortcut.chr(32); }}
                $str.= $first_name.chr(32).$last_name;
                for($aa=0; $aa<$count; $aa++) {
                    if($rows[$aa]->Type == 2) { $str.= ", ".$rows[$aa]->Shortcut; }}}}}
    if($str == "") {
        $str.= $first_name.chr(32).$last_name;}
    return $str;}
function JsonEncode($input,$emulate_old_ver=false) {
    global $MTPS;
    $output = "";
    if($MTPS->PHP >= 5.4 && !$emulate_old_ver) {
        $output = json_encode($input,JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE);}
    else {
        $output = json_encode($input);
        $output = preg_replace_callback(
            '/\\\\u([0-9a-f]{4})/i',
            function ($matches) {
                $sym = mb_convert_encoding(
                    pack('H*', $matches[1]),
                    'UTF-8',
                    'UTF-16');
                $sym = str_replace(chr(11),"",$sym);
                return $sym;
            },$output);
        $output = str_replace("\\/","/",$output);}
    return $output;}
function curl($url) {
    $ch = curl_init();
    $timeout = 0;
    curl_setopt($ch,CURLOPT_URL,$url);
    curl_setopt($ch,CURLOPT_USERAGENT,"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.131 Safari/537.36");
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
    curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,false);
    curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);
    curl_setopt($ch,CURLOPT_MAXREDIRS,999);
    @curl_setopt($ch,CURLOPT_FOLLOWLOCATION,1);
    curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
    $data = curl_exec($ch);
    curl_close($ch);
    return $data;}
function file_get_contents_utf8($fn) {
    pBodyP($fn);
    $opts = array(
        'http' => array(
            'method'=>"GET",
            'header'=>"Content-Type: text/html; charset=utf-8"));
    $context = stream_context_create($opts);
    $result = @file_get_contents($fn,false,$context);
    return $result;}
function DownloadFile($url,$path) {
    $newfname = $path;
    pBodyL("DownloadFile FROM: ".$url);
    $file = fopen($url,"rb");
    if($file) {
        pBodyL("DownloadFile TO: ".$path);
        $newf = fopen($newfname,"wb");
        if($newf) {
            pBodyL("DownloadFile 3");
            while(!feof($file)) {
                $data = fread($file,2048);
                fwrite($newf,$data,2048);}}}
    if($file) {
        fclose($file);}
    if($newf) {
        fclose($newf);}
    pBodyL("-----");}
function EncodeUrlFilename($path) {
    $path = str_replace(chr(32),"+",$path);
    $arr = explode("/",$path);
    $new_path = "";
    $counter = 0;
    foreach($arr as $key => $val) {
        if($counter > 0) { $new_path.= "/"; }
        $new_path.= rawurlencode($val);
        $counter++;}
    $new_path = str_replace("http%3A//","http://",$new_path);
    $new_path = str_replace("%2B","%20",$new_path);
    $new_path = str_replace("%25","%",$new_path);
    return $new_path;}
function klecebendaOdeslatPoptavku() {
    $folder = false;
    if($_FILES['frmPriloha']["error"] == 0) {
        $folder = "prilohy-poptavek/".Date("Y")."/".Date("m")."/".Date("d")."/";
        @is_dir($GLOBALS['fileWEB'].$folder); @mkdir($GLOBALS['fileWEB'].$folder,0775,true);
        $ext = GetFileExtension($_FILES['frmPriloha']['name'],$file);
        move_uploaded_file($_FILES['frmPriloha']['tmp_name'],$GLOBALS['fileWEB'].$folder.PageNameToDirName($file)." (".Time().").".$ext);}
    $text = "";
    $text.= "<h1 style=\"font-size: 150%;\">Poptávka z webového formuláře ze dne ".DateStr()."</h1>";
    $text.= "<h2 style=\"font-size: 125%;\">Celé jméno:</h2>";
    $text.= "<p>".$_POST['frmFullName']."</p>";
    $text.= "<h2 style=\"font-size: 125%;\">Adresa:</h2>";
    $text.= "<p>".$_POST['frmAddress']."</p>";
    $text.= "<h2 style=\"font-size: 125%;\">E-mail:</h2>";
    $text.= "<p>".$_POST['frmEmail']."</p>";
    $text.= "<h2 style=\"font-size: 125%;\">Telefon:</h2>";
    $text.= "<p>".$_POST['frmTelephone']."</p>";
    $text.= "<h2 style=\"font-size: 125%;\">Rozměry:</h2>";
    $text.= "<p>".$_POST['frmRozmery']."</p>";
    $text.= "<h2 style=\"font-size: 125%;\">Popis zakázky:</h2>";
    $text.= "<p>".$_POST['frmPopis']."</p>";
    $text.= "<h2 style=\"font-size: 125%;\">Příloha:</h2>";
    if($folder === false) { $text.= "<p>Žádná příloha</p>"; } else { $text.= "<p><a href=\"".$GLOBALS['urlWEB'].$folder.PageNameToDirName($file)." (".Time().").".$ext."\" target=\"_blank\">".$GLOBALS['urlWEB'].$folder.PageNameToDirName($file)." (".Time().").".$ext."</a></p>"; }
    SendEmail(true,1,"tombenda@atlas.cz","Ing. Tomáš Benda","Poptávka z webového formuláře ze dne ".DateStr(),$text,false,"",0,$_POST['frmEmail'],$_POST['frmFullName']);
    AddSuccess("Vaše poptávka byla úspěšně odeslána. Děkuji, brzy Vás budu kontaktovat.");
    return false;}
function customform_Send_NapisteNam() {
    $folder = false;
    if($_FILES['frmAttachment']["error"] == 0) {
        $folder = "files/write-to-us-attachments/".Date("Y")."/".Date("m")."/".Date("d")."/";
        @is_dir($GLOBALS['fileWEB'].$folder); @mkdir($GLOBALS['fileWEB'].$folder,0775,true);
        $ext = GetFileExtension($_FILES['frmAttachment']['name'],$file);
        move_uploaded_file($_FILES['frmAttachment']['tmp_name'],$GLOBALS['fileWEB'].$folder.PageNameToDirName($file)." (".Time().").".$ext);}
    $text = "";
    $text.= "<h1 style=\"font-size: 150%;\">Dotaz z webového formuláře ze dne ".DateStr()."</h1>";
    $text.= "<h2 style=\"font-size: 125%;\">Celé jméno:</h2>";
    $text.= "<p>".$_POST['frmFullName']."</p>";
    $text.= "<h2 style=\"font-size: 125%;\">E-mail:</h2>";
    $text.= "<p>".$_POST['frmEmail']."</p>";
    $text.= "<h2 style=\"font-size: 125%;\">Předmět:</h2>";
    $text.= "<p>".$_POST['frmSubject']."</p>";
    $text.= "<h2 style=\"font-size: 125%;\">Text:</h2>";
    $text.= "<p>".$_POST['frmText']."</p>";
    $text.= "<h2 style=\"font-size: 125%;\">Příloha:</h2>";
    if($folder === false) { $text.= "<p>Žádná příloha</p>"; } else { $text.= "<p><a href=\"".$GLOBALS['urlWEB'].$folder.PageNameToDirName($file)." (".Time().").".$ext."\" target=\"_blank\">".$GLOBALS['urlWEB'].$folder.PageNameToDirName($file)." (".Time().").".$ext."</a></p>"; }
    SendEmail(true,2,SettingsStr('Form.WriteToUs.RecipientEmail'),SettingsStr('Form.WriteToUs.RecipientEmail'),"Dotaz z webového formuláře ze dne ".DateStr(),$text,false,"",0,$_POST['frmEmail'],$_POST['frmFullName']);
    AddSuccess("Vaše zpráva byla úspěšně odeslána.<br />Pokud jste vyplnili správně Váš e-mail \"".XSS($_POST['frmEmail'])."\", brzy Vás budeme kontaktovat zpět.");
    $_POST['frmFullName'] = "";
    $_POST['frmEmail'] = "";
    $_POST['frmSubject'] = "";
    $_POST['frmText'] = "";
    return true;}
function AddSlashToEnd($str) {
    $len = strlen($str);
    if(strpos($str,"/",$len-1) === false) { $str.= "/"; }
    return $str;}
function RemoveSlashFromEnd($str) {
    $len = strlen($str);
    for($aa=0; $aa<$len; $aa++) {
        if(strpos($str,"/",$len-1) !== false) { $str = substr($str,0,$len-1); $len = strlen($str); }
        else { break; }}
    return $str;}
function CountFileSizeInMB($size) {
    $size/= 1024;
    $size/= 1024;
    return number_format(round($size,2), 2, ',', ' ')." MB";}
function CountFileSizeInOptimalUnits($size) {
    if($size < 1024) { return number_format(round($size,2), 0, ',', '&nbsp;')."&nbsp;B"; }
    $size/= 1024;
    if($size < 1024) { return number_format(round($size,2), 2, ',', '&nbsp;')."&nbsp;kB"; }
    $size/= 1024;
    return number_format(round($size,2), 2, ',', '&nbsp;')."&nbsp;MB";}
function GetFileIconByExtension($ext) {
    $ext = strtolower($ext);
    if(file_exists($GLOBALS['fileIMG']."files/".$ext.".png")) {
        return $GLOBALS['urlIMG']."files/".$ext.".png";}
    switch($ext) {
        case "jpg": case "jpeg": case "png": case "gif": case "tif": case "tiff": case "bmp": case "ico":
        $filename = "picture";
        break;
        case "exe":
            $filename = "application";
            break;
        case "msi":
            $filename = "installer";
            break;
        case "mp3": case "wma": case "wav": case "ogg":
        $filename = "audio";
        break;
        case "avi": case "wmv": case "mkv": case "mp4":
        $filename = "video";
        break;
        case "htm": case "html": case "url":
        $filename = "web";
        break;
        default:
            $filename = "default";
            break;}
    return $GLOBALS['urlIMG']."files/".$filename.".png";}
function DeleteAllFilesInFolder($path) {
    $path = AddSlashToEnd($path);
    if(file_exists($path) && $handle = opendir($path)) {
        while(false !== ($file = readdir($handle))) {
            if($file != "." && $file != "..") {
                $dirhandle = @opendir($path.$file);
                if($dirhandle != false) {
                    DeleteAllFilesInFolder($path.$file);
                    rmdir($path.$file);}
                else {
                    DeleteFile($path.$file);}}}
        closedir($handle);}}
function RemoveLastFolderFromPath($path) {
    $new_path = "";
    $path = RemoveSlashFromEnd($path);
    $arr = explode("/",$path);
    for($aa=0; $aa<count($arr)-1; $aa++) {
        $new_path.= $arr[$aa]."/";}
    return $new_path;}
function RemoveDomainAndGalleryFromPath($path) {
    $new_path = "";
    $path = RemoveSlashFromEnd($path);
    $arr = explode("/",$path);
    $pos = -1;
    for($aa=0; $aa<count($arr); $aa++) {
        if($pos > -1 && $aa > $pos) {
            $new_path.= $arr[$aa];
            if($aa < count($arr)-1) { $new_path.= "/"; }}
        if($arr[$aa] == "gallery") {
            $pos = $aa;}}
    if($pos > -1) { return $new_path; }
    return $path;}
function GetLastPath($path) {
    $new_path = "";
    $path = RemoveSlashFromEnd($path);
    $arr = explode("/",$path);
    $pos = count($arr)-1;
    return $arr[$pos];}
function GetSizeInPixels($str) {
    global $MTPS;
    if(strpos($str,"px") !== false) {
        return intval(str_replace("px","",$str),10);}
    if(strpos($str,"em") !== false) {
        return (intval(str_replace("em","",$str),10)*$MTPS->EM);}
    if(strpos($str,"%") !== false) {
        return ((($MTPS->EM*$MTPS->MaxInPageImageWidth)*intval(str_replace("%","",$str),10))/100);}
    return $str;}
function GetParamsFromImg($img) {
    $params = array();
    $params['src'] = "";
    $params['alt'] = "";
    $params['style'] = "";
    if(($pos = strpos($img,"src=\"")) !== false) {
        $pos+= 5; if(($end = strpos($img,"\"",$pos)) !== false) { $params['src'] = substr($img,$pos,$end-$pos); }}
    else if(($pos = strpos($img,"src='")) !== false) {
        $pos+= 5; if(($end = strpos($img,"'",$pos)) !== false) { $params['src'] = substr($img,$pos,$end-$pos); }}
    if(($pos = strpos($img,"alt=\"")) !== false) {
        $pos+= 5; if(($end = strpos($img,"\"",$pos)) !== false) { $params['alt'] = substr($img,$pos,$end-$pos); }}
    else if(($pos = strpos($img,"alt='")) !== false) {
        $pos+= 5; if(($end = strpos($img,"'",$pos)) !== false) { $params['alt'] = substr($img,$pos,$end-$pos); }}
    if(($pos = strpos($img,"style=\"")) !== false) {
        $pos+= 7; if(($end = strpos($img,"\"",$pos)) !== false) { $params['style'] = substr($img,$pos,$end-$pos); }}
    else if(($pos = strpos($img,"style='")) !== false) {
        $pos+= 7; if(($end = strpos($img,"'",$pos)) !== false) { $params['style'] = substr($img,$pos,$end-$pos); }}
    $_style = $params['style'];
    $twospaces = chr(32).chr(32);
    while(strpos($_style,$twospaces) !== false) { $_style = str_replace($twospaces,chr(32),$_style); }
    $_style = str_replace(":".chr(32),":",$_style);
    $_style = str_replace(";".chr(32),";",$_style);
    $styles = explode(";",$_style);
    foreach($styles as $key => $value) {
        $att = explode(":",$value);
        if(IsSet($att[1])) {
            $n = strtolower($att[0]);
            $params[$n] = $att[1];}}
    return $params;}
function ImageCreateFromAny($filepath) {
    $type = exif_imagetype($filepath);
    $allowedTypes = array(
        1,
        2,
        3,
        6);
    if(!in_array($type, $allowedTypes)) {
        return false;}
    ini_set("gd.jpeg_ignore_warning",1);
    switch($type) {
        case 1: $im = imageCreateFromGif($filepath); break;
        case 2: $im = imageCreateFromJpeg($filepath); break;
        case 3: $im = imageCreateFromPng($filepath); break;
        case 6: $im = imageCreateFromBmp($filepath); break;}
    return $im;}
function ToBool2($val) {
    if($val == 0 || $val == false) { return false; }
    return true;}
function ToBool($val) {
    if(is_numeric($val)) {
        if($val <= 0 || $val == false) { return false; } else { return true; }}
    else {
        if(strtolower($val) == "false" || $val == "0") { return false; } else { return true; }}}
function GetYoutubeVideoInfo($video_id,&$arr) {
    $content = curl("https://www.youtube.com/watch?v=".$video_id);
    if(($arr['Title'] = FindBetween($content,"<meta name=\"title\" content=\"","\"")) !== false) {
        $arr['Image'] = FindBetween($content,"<meta name=\"twitter:image\" content=\"","\"");
        return true;}
    return false;}
function DeleteFile($filename_with_full_path) {
    if(strlen($filename_with_full_path) > 0) {
        return unlink($filename_with_full_path);}
    return false;}
function TextizeHyperlinks($text) {
    $link_start = 0; $link_posX = 0; $link_pos2 = 0;
    while(($begin = FindBetween($text,"<a",">",$link_start,$link_posX,$link_pos2)) !== false) {
        $start2 = 0; $posX2 = 0;
        if(($link = FindBetween($begin,"href=\"","\"",$start2,$posX2)) === false) {
            $link = FindBetween($begin,"href='","'",$start2,$posX2);}
        if($link !== false) {
            $link = str_replace("https://","",$link);
            $link = str_replace("http://","",$link);
            $link = str_replace("ftp://","",$link);
            $posX = $link_pos2; $start = 0;
            if(($link_text = FindBetween($text,">","</a>",$start,$posX)) !== false) {
                $newpos = $link_pos2 + strlen($link_text) + 1;
                $insert = " [".$link."]";
                $text1 = substr($text,0,$newpos);
                $text2 = substr($text,$newpos);
                $text = $text1.$insert.$text2;}}
        $link_start = 0;}
    return $text;}
function GetPlainText($text,$void="") {
    $text = str_replace("</div>","\n",$text);
    $text = str_replace("</p>","\n",$text);
    $text = str_replace("<br />","\n",$text);
    $text = str_replace("<br/>","\n",$text);
    $text = str_replace("<br>","\n",$text);
    $text = str_replace("&nbsp;",chr(32),$text);
    $text = str_replace(">","> ",$text);
    while(strpos($text,chr(32).chr(32)) !== false) { $text = str_replace(chr(32).chr(32),chr(32),$text); }
    $text = trim($text);
    while(strpos($text,"href ") !== false) { $text = str_replace("href ","href",$text); }
    while(strpos($text,"href= ") !== false) { $text = str_replace("href= ","href=",$text); }
    $text = TextizeHyperlinks($text);
    $text = strip_tags($text);
    while(strpos($text,chr(32)."\r") !== false) { $text = str_replace(chr(32)."\r","\n",$text); }
    while(strpos($text,"\r\n") !== false) { $text = str_replace("\r\n","\n",$text); }
    while(strpos($text,"\n\r") !== false) { $text = str_replace("\n\r","\n",$text); }
    while(strpos($text,chr(32)."\n") !== false) { $text = str_replace(chr(32)."\n","\n",$text); }
    while(strpos($text,"\n\n") !== false) { $text = str_replace("\n\n","\n",$text); }
    while(strpos($text,chr(32).":") !== false) { $text = str_replace(chr(32).":",":",$text); }
    $text = RepairUTF8($text);
    $text = trim($text);
    if($text == "" || $text == chr(32)) { $text = $void; }
    return $text;}
function PlainText($text) {
    $text = str_replace(">","> ",$text);
    while(strpos($text,chr(32).chr(32)) !== false) { $text = str_replace(chr(32).chr(32),chr(32),$text); }
    $text = str_replace(" :",":",$text);
    $text = trim($text);
    $text = strip_tags($text);
    $text = str_replace("\n",chr(32),$text);
    $text = RepairUTF8($text);
    return $text;}
function IsReservedPath($name) {
    switch(strtolower($name)) {
        case "":
        case "manual":
        case "kiosk":
        case "info":
        case "help":
        case "napoveda":
        case "neprihlaseny":
        case "support":
        case "podpora":
        case "tools":
        case "nastroje":
        case "admin":
        case "pim":
        case "uzivatel":
        case "uzivatele":
        case "uzivatelske-jmeno":
        case "uzivatelskejmeno":
        case "username":
        case "user":
        case "users":
        case "rss":
        case "css":
        case "image":
        case "box":
        case "blog":
        case "vlog":
        case "eshop":
        case "shop":
        case "buy":
        case "news":
        case "aktuality":
        case "contacts":
        case "kontakty":
        case "today":
        case "dnes":
        case "search":
        case "vyhledavani":
        case "documents":
        case "dokumenty":
        case "document":
        case "dokument":
        case "people":
        case "lide":
        case "appointments":
        case "udalosti":
        case "events":
        case "akce":
        case "services":
        case "sluzby":
        case "calendar":
        case "kalendar":
        case "calendars":
        case "kalendare":
        case "day":
        case "den":
        case "agenda":
        case "week":
        case "tyden":
        case "month":
        case "mesic":
        case "year":
        case "rok":
        case "settings":
        case "nastaveni":
        case "config":
        case "configuration":
        case "konfigurace":
        case "find":
        case "najit":
        case "tasks":
        case "ukoly":
        case "notes":
        case "poznamky":
        case "task":
        case "ukol":
        case "note":
        case "poznamka":
        case "event":
        case "udalost":
        case "apointment":
        case "meeting":
        case "schuzka":
        case "meetings":
        case "schuzky":
        case "project":
        case "projekt":
        case "projects":
        case "projekty":
        case "tag":
        case "stitek":
        case "tags":
        case "stitky":
        case "diary":
        case "denik":
        case "diaries":
        case "deniky":
        case "auth":
        case "authorization":
        case "autorizace":
        case "buy-license":
        case "koupit-licenci":
        case "license":
        case "licence":
        case "licenses":
        case "password-change":
        case "zmena-hesla":
        case "password":
        case "heslo":
        case "passwords":
        case "hesla":
        case "article":
        case "clanek":
        case "articles":
        case "clanky":
        case "page":
        case "stranka":
        case "pages":
        case "stranky":
        case "forgotten-password":
        case "zapomenute-heslo":
        case "new-password":
        case "nove-heslo":
        case "account":
        case "ucet":
        case "accounts":
        case "ucty":
        case "administration":
        case "administrace":
        case "download-file":
        case "ajax":
        case "login":
        case "desk":
        case "cron":
        case "intranet":
        case "api":
        case "image":
        case "forms":
        case "utils":
        case "utility":
            return true;}
    return false;}
function TestUniqueUrlPath($vals,&$arr) {
    global $MTPS, $DB;
    if(Settings('EnableUniqueUrlPaths')) {
        if(IsSet($vals['UrlPath'])) {
            if(($rows = $DB->Select("UniqueUrlPaths","`Path` = '".DBText($vals['UrlPath'])."'",$count)) !== false) {
                if($count <= 0) {
                    if(IsReservedPath($vals['UrlPath'])) {
                        $arr['Response'] = Lng('UsernameIsTaken');}
                    else {
                        return true;}}
                else {
                    $arr['Response'] = Lng('UsernameIsTaken');}}
            else {
                $arr['Response'] = "[TestUniqueUrlPath] Database error!";}}
        else {
            $arr['Response'] = "[TestUniqueUrlPath] UrlPath not defined!";}}
    else {
        $arr['Response'] = "[TestUniqueUrlPath] Not enabled by settings!";}
    return false;}
function IsUniqueUrlPathAllowedChar($char) {
    $list = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-._0123456789";
    for($aa=0; $aa<strlen($list); $aa++) {
        if($char == $list[$aa]) { return true; }}
    return false;}
function StringContainsOnlyUniqueUrlPathAllowedChars($name) {
    for($aa=0; $aa<strlen($name); $aa++) {
        if(!IsUniqueUrlPathAllowedChar($name[$aa])) { return false; }}
    return true;}
function SaveUniqueUsernameUrlPath($vals,&$arr) {
    global $DB;
    $arr['ReloadToURL'] = "";
    if(Settings('EnableUniqueUrlPaths') && Settings('EnableUniqueUrlPaths_Usernames')) {
        if(IsSet($vals['Username'])) {
            if(strlen($vals['Username']) >= 3 && strlen($vals['Username']) <= 128) {
                if(StringContainsOnlyUniqueUrlPathAllowedChars($vals['Username'])) {
                    if(!is_numeric($vals['Username'])) {
                        $vals['UrlPath'] = $vals['Username'];
                        if(TestUniqueUrlPath($vals,$arr)) {
                            if(IsSet($data)) { unset($data); }
                            $data['Type'] = 1;
                            $data['Path'] = $vals['Username'];
                            $data['RedirectID'] = GetUserAccountID();
                            $path_id = $DB->Insert("UniqueUrlPaths",$data,$arr['Response']);
                            if($path_id > 0) {
                                $DB->Delete("UniqueUrlPaths","`Type` = '1' AND `RedirectID` = '".DBText(GetUserAccountID())."' AND `ID` != '".DBText($path_id)."'");
                                $DB->Update("Users","`UsernamePath` = '".DBText($vals['Username'])."', ","`ID` = '".DBText(GetUserAccountID())."'");
                                if(ModuleEnabled('pim')) {
                                    $set = "`UsernamePath` = '".DBText($vals['Username'])."', ";
                                    $DB->Update("PIM_Contacts",$set,"`ContactUserID` = '".DBText(GetUserAccountID())."'");}
                                $arr['ReloadToURL'] = $GLOBALS['urlWEB'].$vals['Username'];
                                return true;}}}
                    else {
                        $arr['Response'] = "[SaveUniqueUsernameUrlPath] Username can't be number!";}}
                else {
                    $arr['Response'] = "[SaveUniqueUsernameUrlPath] Username contains unallowed characters!";}}
            else {
                $arr['Response'] = "[SaveUniqueUsernameUrlPath] Username is too short or too long!";}}
        else {
            $arr['Response'] = "[SaveUniqueUsernameUrlPath] Username not defined!";}}
    else {
        $arr['Response'] = "[SaveUniqueUsernameUrlPath] Not enabled by settings!";}
    return false;}
function LoadUniqueUrlPath($path) {
    global $DB;
    if(($rows = $DB->Select("UniqueUrlPaths","`Path` = '".DBText($path)."'",$count)) !== false && $count > 0) {
        return $rows[0];}
    return false;}
function GetUniqueUrlPathData($vals,&$arr) {
    global $MTPS, $DB, $User;
    if(Settings('EnableUniqueUrlPaths')) {
        if(IsSet($vals['UrlPath'])) {
            if(($rows = $DB->Select("UniqueUrlPaths","`Path` = '".DBText($vals['UrlPath'])."'",$count)) !== false && $count > 0) {
                $arr['Data'] = $rows[0];
                switch($rows[0]->Type) {
                    case 1:
                        if(($arr['UsersPublicData'] = $User->LoadUsersPublicDataByID($rows[0]->RedirectID)) !== false) {}
                        else {
                            $arr['Data'] = false;}
                        break;
                    default:
                        $arr['Data'] = false;
                        break;}
                return true;}
            else {
                $arr['Response'] = "[GetUniqueUrlPathData] Database error!";}}
        else {
            $arr['Response'] = "[GetUniqueUrlPathData] UrlPath not defined!";}}
    else {
        $arr['Response'] = "[GetUniqueUrlPathData] Not enabled by settings!";}
    return false;}
function GetUsersAffiliateStats($vals,&$arr) {
    global $DB, $User;
    if($User->Logged && Settings('EnableUserInvitedBy')) {
        if(IsSet($vals['UserID']) && is_numeric($vals['UserID']) && $vals['UserID'] > 0 && $User->Account->ID = $vals['UserID']) {
            $str = "";
            $str.= "<table class=\"tab-affiliate-stats\">";
            $DB->Select("Users","`InvitedBy` = '".DBText($vals['UserID'])."'",$users_count);
            $str.= "<tr><th>Počet registrovaných uživatelů:</th><td>".$users_count."</td><td>".Price($users_count*10*100)."</td></tr>";
            $licenses_count = 0;
            $str.= "<tr><th>Počet zakoupených licencí:</th><td>".$licenses_count."</td><td>".Price($licenses_count*100*100)."</td></tr>";
            $str.= "<tr><th>Zisk celkem:</th><td colspan=\"2\">".Price($users_count*10*100+$licenses_count*100*100)."</td></tr>";
            $str.= "</table>";
            $arr['Response'] = $str;
            return true;}}
    return false;}
function DefaultURL($url) {
    global $MTPS;
    if($MTPS->DefaultURL == $url) { return ""; }
    return $url."/";}
function GetAppVersionStr($version) {
    return number_format(($version/100),2,'.',' ');}
function Odoprag_LoadCars($vals,&$arr) {
    global $DB, $User;
    $arr['Response'] = "";
    $items = array();
    if(($rows = $DB->Select("Cars","1",$count,"`SortPos` ASC, `Created` ASC")) !== false && $count >= 0) {
        for($aa=0; $aa<$count; $aa++) {
            $items[$aa] = $rows[$aa];
        }
        $arr['Items'] = $items;
        return true;}
    return false;}
function Odoprag_EditCar($vals,&$arr) {
    global $DB, $User;
    $arr['Response'] = "";
    if($User->Logged && IsSet($vals['ItemID']) && is_numeric($vals['ItemID']) && $vals['ItemID'] >= 0) {
        if($vals['ItemID'] == 0) {
            if(IsSet($data)) { unset($data); }
            $data['SortPos'] = Odoprag_GetCarsLastSortPos();
            $arr['ItemID'] = $DB->Insert("Cars",$data,$arr['Response']);
            $vals['ItemID'] = $arr['ItemID'];}
        if($vals['ItemID'] > 0) {
            $arr['ItemID'] = $vals['ItemID'];
            $set = "";
            $n = "Title"; if(IsSet($vals[$n])) { $set.= "`".$n."` = '".DBText($vals[$n])."', "; }
            $n = "MinDays"; if(IsSet($vals[$n])) { $set.= "`".$n."` = '".DBText($vals[$n])."', "; }
            $n = "Deposit"; if(IsSet($vals[$n])) { $set.= "`".$n."` = '".DBText($vals[$n]*100)."', "; }
            $n = "Text"; if(IsSet($vals[$n])) { $set.= "`".$n."` = '".DBText($vals[$n])."', "; }
            $n = "SpecialTitle"; if(IsSet($vals[$n])) { $set.= "`".$n."` = '".DBText($vals[$n])."', "; }
            $n = "FullTitle"; if(IsSet($vals[$n])) { $set.= "`".$n."` = '".DBText($vals[$n])."', "; }
            $n = "ShowInCalc"; if(IsSet($vals[$n])) { $set.= "`".$n."` = '".DBText($vals[$n])."', "; }
            $n = "AlbumID"; if(IsSet($vals[$n])) { $set.= "`".$n."` = '".DBText($vals[$n])."', "; }
            $DB->Update("Cars",$set,"`ID` = '".DBText($arr['ItemID'])."'",$arr['Response']);
            return true;}}
    else {
        $arr['Response'] = "[Odoprag_EditCar] Uživatel není přihlášen nebo není definováno ItemID!";}
    return false;}
function Odoprag_DeleteOdopragCar($vals,&$arr) {
    global $DB;
    if(IsSet($vals['ItemID']) && is_numeric($vals['ItemID'])) {
        return $DB->Delete("Cars","`ID` = '".DBText($vals['ItemID'])."'");}
    return false;}
function Odoprag_GetCarsLastSortPos() {
    global $DB;
    $sortpos = 1;
    if(($attachments = $DB->Select("Cars","1",$count,"`SortPos` ASC, `Created` ASC")) !== false && $count > 0) {
        for($aa=0; $aa<$count; $aa++) {
            if($attachments[$aa]->SortPos > $sortpos) { $sortpos = $attachments[$aa]->SortPos; }
            else { $sortpos++; }}}
    return $sortpos;}
function Odoprag_RenewCarsSortPos($survey_id) {
    global $DB;
    if(($attachments = $DB->Select("Cars","1",$count,"`SortPos` ASC, `Created` ASC")) !== false && $count > 0) {
        for($aa=0; $aa<$count; $aa++) {
            $set = "`SortPos` = '".DBText(($aa+1))."', ";
            $DB->Update("Cars",$set,"`ID` = '".DBText($attachments[$aa]->ID)."'");}}}
function Odoprag_MoveOdopragCar($vals,&$arr,$second_pass=false) {
    global $DB, $MTPS, $User;
    $sort_pos = array();
    if(IsSet($vals['Move']) && IsSet($vals['ItemID']) && is_numeric($vals['ItemID'])) {
        $move = $vals['Move'];
        $tile_id = $vals['ItemID'];
        if(($tiles = $DB->Select("Cars","1",$count,"`SortPos` ASC, `Created` ASC")) !== false && $count > 0) {
            $moved_att_pos = -1;
            for($aa=0; $aa<$count; $aa++) {
                if($tiles[$aa]->ID == $tile_id) {
                    $moved_att_pos = $aa;}
                $n = 'sp'.$tiles[$aa]->SortPos;
                if(IsSet($sort_pos[$n]) && !$second_pass) {
                    Odoprag_RenewCarsSortPos();
                    return Odoprag_MoveOdopragCar($vals,$arr,true);}
                else {
                    $sort_pos[$n] = 1;}}
            if($moved_att_pos != -1) {
                $replacement_pos = $moved_att_pos;
                if($move == 'up' && $moved_att_pos > 0) {
                    $replacement_pos = $moved_att_pos-1;}
                if($move == 'down' && $moved_att_pos < $count-1) {
                    $replacement_pos = $moved_att_pos+1;}
                $set = "`SortPos` = '".DBText($tiles[$replacement_pos]->SortPos)."', ";
                $DB->Update("Cars",$set,"`ID` = '".DBText($tiles[$moved_att_pos]->ID)."'");
                $set = "`SortPos` = '".DBText(($tiles[$moved_att_pos]->SortPos))."', ";
                $DB->Update("Cars",$set,"`ID` = '".DBText($tiles[$replacement_pos]->ID)."'");
                return true;}
            else {
                $arr['Response'] = "[Web::Odoprag_MoveOdopragCar] moved_att_pos error!";}}
        else {
            $arr['Response'] = "[Web::Odoprag_MoveOdopragCar] Database error!";}}
    else {
        $arr['Response'] = "[Web::Odoprag_MoveOdopragCar] Unknown error!";}
    return false;}
function Odoprag_LoadPricelist($vals,&$arr) {
    global $DB, $User;
    $arr['Response'] = "";
    $items = array();
    if($User->Logged && IsSet($vals['CarID']) && is_numeric($vals['CarID']) && $vals['CarID'] > 0) {
        if(($rows = $DB->Select("Pricelist","`CarID` = '".DBText($vals['CarID'])."'",$count,"`MaxDays` ASC, `Created` ASC")) !== false && $count >= 0) {
            for($aa=0; $aa<$count; $aa++) {
                $items[$aa] = $rows[$aa];}
            $arr['Items'] = $items;
            return true;}}
    else {
        $arr['Response'] = "[Odoprag_LoadItems] Uživatel není přihlášen nebo není definováno CarID!";}
    return false;}
function Odoprag_LoadFullPricelist($vals,&$arr) {
    global $DB, $User;
    $arr['Response'] = "";
    $items = array();
    if(($rows = $DB->Select("Pricelist","1",$count,"`MaxDays` ASC, `Created` ASC")) !== false && $count >= 0) {
        for($aa=0; $aa<$count; $aa++) {
            $items[$aa] = $rows[$aa];}
        $arr['Items'] = $items;
        return true;}
    return false;}
function Odoprag_EditPricelist($vals,&$arr) {
    global $DB, $User;
    $arr['Response'] = "";
    if($User->Logged && IsSet($vals['CarID']) && is_numeric($vals['CarID']) && $vals['CarID'] > 0) {
        $DB->Delete("Pricelist","`CarID` = '".DBText($vals['CarID'])."'");
        $count = 0;
        for($aa=0; $aa<20; $aa++) {
            $n = "MaxDays".$aa;
            $m = "Price".$aa;
            $s = "Sale".$aa;
            if(IsSet($vals[$n]) && $vals[$n] != "" && IsSet($vals[$m]) && $vals[$m] != "") {
                if(is_numeric($vals[$n]) && is_numeric($vals[$n])) {
                    if(IsSet($data)) { unset($data); }
                    $data['CarID'] = $vals['CarID'];
                    $data['MaxDays'] = $vals[$n];
                    $data['Price'] = $vals[$m]*100;
                    $data['Sale'] = 0;
                    if(IsSet($vals[$s]) && is_numeric($vals[$s]) && $vals[$s] > 0) { $vals[$s]*100; }
                    $DB->Insert("Pricelist",$data,$arr['Response']);}}}
        return true;}
    else {
        $arr['Response'] = "[Odoprag_Editpricelist] Uživatel není přihlášen nebo není definováno CarID!";}
    return false;}
function getSettings($name,$user_id=0) {
    global $DB;
    $tabPrimary = "Settings";
    if(($rows = $DB->Select($tabPrimary,"`Name` = '".DBText($name)."' AND `UserID` = ".DBText($user_id)."",$count)) !== false && $count > 0) {
        return $rows[0];}
    return false;}
function setSettings($name,$user_id=0,$num=0,$data="") {
    global $DB;
    $tabPrimary = "Settings";
    if(($settings = getSettings($name,$user_id)) !== false) {
        $set = "`Num`=".DBText($num).",";
        $set.= "`Data`='".DBText($data)."',";
        $DB->Update($tabPrimary,$set,"`ID`=".DBText($settings->ID));}
    else {
        if(IsSet($data)) { unset($data); }
        $data['Name'] = $name;
        $data['UserID'] = $user_id;
        $data['Num'] = $num;
        $data['Data'] = $data;
        return $DB->Insert($tabPrimary,$data);}}
function removeVoidItemsFromArray($array) {
    $count = count($array);
    $new = array();
    $new_count = 0;
    for($aa=0; $aa<$count; $aa++) {
        if(trim($array[$aa]) != "") { $new[$new_count] = $array[$aa]; $new_count++; }}
    return $new;}
function valueIsInArray($arr,$val) {
    for($aa=0; $aa<count($arr); $aa++) {
        if($arr[$aa] == $val) { return true; }}
    return false;}
function createMPDF($margin_left=15,$margin_right=15,$margin_top=15,$margin_bottom=15) {
    return new mPDF('utf-8','A4',9,'Helvetica',$margin_left,$margin_right,$margin_top,$margin_bottom,0,0,'');}
function getJsonHtmlString($source,$id,$style="display:none") {
    $json = "<div id=\"".$id."\" style=\"".$style."\">";
    $json.= json_encode($source);
    $json.= "</div>";
    return $json;}
$___mtps3file = $fileWEB."scripts/php/fncs.php";
if(@file_exists($___mtps3file)) { include_once($___mtps3file); }
$___mtps3file = $fileWEB."templates/".$MTPS->DefaultLayout."/scripts/php/fncs.php";
if(@file_exists($___mtps3file)) { include_once($___mtps3file); }
$MTPS->WebLanguagesCount = GetWebLanguages($MTPS->WebLanguages);
error_reporting(E_ALL ^ E_DEPRECATED);
set_error_handler("ErrorHandler");
$MTPS->IP = MyIP();
$browser = GetBrowser();
$MTPS->BrowserName = $browser['name'];
$MTPS->BrowserVersion = $browser['major_version'];
if(ModuleEnabled('pim') && $MTPS->PathOne == "pim" && $MTPS->PathTwo == "box") { $MTPS->ShowingPIMBox = true; }
if(IsSet($_GET['SetClientLayout'])) {
    SetCookie("ClientLayout",$_GET['SetClientLayout'],Time()+90*24*60*60,'/');
    $MTPS->ClientLayout = $_GET['SetClientLayout'];}
else if(IsSet($_COOKIE['ClientLayout'])) {
    $MTPS->ClientLayout = $_COOKIE['ClientLayout'];}
if(IsSet($_GET['FromMobileApp']) && $_GET['FromMobileApp'] == "true") { $FromMobileApp = true; } else { $FromMobileApp = false; }
if(IsSet($_GET['WebAppVersion'])) { $MobileAppVersion = intval($_GET['WebAppVersion'],10); } else { $MobileAppVersion = 0; }
if($MobileAppVersion < 0) { $MobileAppVersion = 0; }
if(IsSet($_GET['Lng']) && IsLanguage($_GET['Lng'])) { $MTPS->Language = $_GET['Lng']; }
if(!IsLanguage($MTPS->Language)) { if(IsSet($MTPS->DefaultLanguage) && IsLanguage($MTPS->DefaultLanguage)) { $MTPS->Language = $MTPS->DefaultLanguage; } else { $MTPS->Language = "cs"; } }
if($MTPS->Language != $MTPS->DefaultLanguage) { $urlWEB.= $MTPS->Language."/"; }
$MTPS->URL = $MTPS->URL.@str_replace("//","/",$_SERVER['HTTP_HOST']."/".$_SERVER['REQUEST_URI']);
ClearURL($MTPS->URL);
$urlJS = $urlWEB."js/";
$urlCSS = $urlWEB."css/";
if($MTPS->DefaultURL == "pim") { $urlPIM = $urlWEB; $urlPIM_Prefix = ""; } else { $urlPIM = $urlWEB."pim/"; $urlPIM_Prefix = "pim/"; }
if($MTPS->DefaultURL == "eshop") { $urlESHOP = $urlWEB; $urlESHOP_Prefix = ""; } else { $urlESHOP = $urlWEB."eshop/"; $urlESHOP_Prefix = "eshop/"; }
$urlADMIN = $urlWEB."admin/";
$urlCRON = $urlWEB."cron/";
$urlAJAXGET = $urlWEB."ajax/?";
$urlAJAX = $urlMTPSSSL."?Ajax=true&Lng=".$MTPS->Language;
$urlAJAXSSL = $urlMTPSSSL."?Ajax=true&Lng=".$MTPS->Language;
$urlUPLOADFILE = $urlMTPS."?_UploadFile=true&Lng=".$MTPS->Language;
if($MTPS->PathOne == "pim" && $MTPS->PathTwo == "rss") {}
else if($MTPS->PathOne == "pim" && $MTPS->PathTwo == "box") {}
else if(!$MTPS->HTTPS &&
    IsSet($_COOKIE['UserLoginSSL']) &&
    $_COOKIE['UserLoginSSL'] == 1 &&
    Settings('EnableSSL',true) &&
    $MTPS->PathOne != "cron" &&
    $MTPS->PathOne != "rss" &&
    $MTPS->PathOne != "box"
) {
    $urlssl = str_replace("http://","https://",$MTPS->URL);
    LinkReload($urlssl);}
if(IsSet($_COOKIE['PreviousURL'])) { $MTPS->PreviousURL = $_COOKIE['PreviousURL']; } else { $MTPS->PreviousURL = $MTPS->URL; }
$_URL = $MTPS->URL; if(($pos = strpos($_URL,"?",0)) !== false) { $_URL = substr($_URL,0,$pos); }
if($urlMTPS.$MTPS->MainFile == $_URL) { $IsMainScript = true; } else { $IsMainScript = false; }
class LNG {
    public $created = false;
    public $count = 0;
    public $items = array();
    public $urlCount = 0;
    public $urlItems = array();
    public function add($id,$text) {
        $this->items[$this->count] = new stdClass;
        $this->items[$this->count]->id = $id;
        $this->items[$this->count]->text = $text;
        $this->count++;}
    public function addUrl($id,$text) {
        $this->urlItems[$this->urlCount] = new stdClass;
        $this->urlItems[$this->urlCount]->id = $id;
        $this->urlItems[$this->urlCount]->text = $text;
        $this->urlCount++;}
    public function ver() {
        global $MTPS, $fileWEB;
        $file = $GLOBALS['fileMTPS']."lng/lng-".$MTPS->Language.".php";
        if(file_exists($file)) {
            $ft = filemtime($file);
            $fz = filesize($file);
            for($aa=0; $aa<count($MTPS->kwiModules); $aa++) {
                $___mtps3file = $fileWEB."templates/".$MTPS->DefaultLayout."/modules/".$MTPS->kwiModules[$aa]."/lng/lng-".$MTPS->Language.".php";
                if(@file_exists($___mtps3file)) { $ft = max($ft,filemtime($___mtps3file)); $fz+= filesize($___mtps3file); }}
            $___mtps3file = $fileWEB."scripts/lng/lng-".$MTPS->Language.".php";
            if(@file_exists($___mtps3file)) { $ft = max($ft,filemtime($___mtps3file)); $fz+= filesize($___mtps3file); }
            $___mtps3file = $fileWEB."templates/".$MTPS->DefaultLayout."/scripts/lng/lng-".$MTPS->Language.".php";
            if(@file_exists($___mtps3file)) { $ft = max($ft,filemtime($___mtps3file)); $fz+= filesize($___mtps3file); }
            $str = "<script>";
            $str.= "g_lng='".$MTPS->Language."';";
            $str.= "g_lngTime=".$ft.";";
            $str.= "g_lngSize=".$fz.";";
            $str.= "</script>";
            return $str;}
        return "";}
    public function getTexts($vals,&$arr) {
        global $MTPS, $fileWEB;
        if(!$this->created) { $this->create(); }
        $arr['lng'] = $MTPS->Language;
        $file = $GLOBALS['fileMTPS']."lng/lng-".$MTPS->Language.".php";
        if(file_exists($file)) {
            $ft = filemtime($file);
            $fz = filesize($file);
            for($aa=0; $aa<count($MTPS->kwiModules); $aa++) {
                $___mtps3file = $fileWEB."templates/".$MTPS->DefaultLayout."/modules/".$MTPS->kwiModules[$aa]."/lng/lng-".$MTPS->Language.".php";
                if(@file_exists($___mtps3file)) { $ft = max($ft,filemtime($___mtps3file)); $fz+= filesize($___mtps3file); }}
            $___mtps3file = $fileWEB."scripts/lng/lng-".$MTPS->Language.".php";
            if(@file_exists($___mtps3file)) { $ft = max($ft,filemtime($___mtps3file)); $fz+= filesize($___mtps3file); }
            $___mtps3file = $fileWEB."templates/".$MTPS->DefaultLayout."/scripts/lng/lng-".$MTPS->Language.".php";
            if(@file_exists($___mtps3file)) { $ft = max($ft,filemtime($___mtps3file)); $fz+= filesize($___mtps3file); }
            $arr['lngTime'] = $ft;
            $arr['lngSize'] = $fz;}
        $arr['items'] = $this->items;
        $arr['urlItems'] = $this->urlItems;
        return true;}
    public function create() {
        global $MTPS, $fileWEB;
        switch($MTPS->Language) {
            case "cs":
                $lng = "cs";
                break;
            default:
                $lng = "en";
                break;}
        include_once($GLOBALS['fileMTPS']."lng/lng-".$lng.".php");
        for($aa=0; $aa<count($MTPS->kwiModules); $aa++) {
            $___mtps3file = $fileWEB."templates/".$MTPS->DefaultLayout."/modules/".$MTPS->kwiModules[$aa]."/lng/lng-".$MTPS->Language.".php";
            if(@file_exists($___mtps3file)) { include_once($___mtps3file); }}
        $___mtps3file = $fileWEB."scripts/lng/lng-".$lng.".php";
        if(@file_exists($___mtps3file)) { include_once($___mtps3file); }
        $___mtps3file = $fileWEB."templates/".$MTPS->DefaultLayout."/scripts/lng/lng-".$lng.".php";
        if(@file_exists($___mtps3file)) { include_once($___mtps3file); }
        $this->created = true;}};
$LNG = new LNG;
function ln() {
    global $LNG, $MTPS;
    if(!$LNG->created) { $LNG->create(); }
    $args_count = func_num_args();
    if($args_count > 0 && $MTPS->Language != "") {
        $lng = $MTPS->Language;
        $id = func_get_arg(0);
        $pos = -1;
        for($aa=0; $aa<$LNG->count; $aa++) {
            if($LNG->items[$aa]->id == $id) { $pos = $aa; break; }}
        if($pos > -1) {
            if($args_count > 1) {
                $text = $LNG->items[$pos]->text;
                for($aa=0; $aa<$args_count-1; $aa++) {
                    $str = sprintf("%%%d",$args_count-$aa-1);
                    $pos = $args_count-$aa-1;
                    $dynamic_text = func_get_arg($pos);
                    $text = str_replace($str,$dynamic_text,$text);}
                return $text;}
            return $LNG->items[$pos]->text;}
        return "[!".$id."]";}
    return "[LNG_ERROR]";
}

function lnUrl() {
    global $LNG, $MTPS;
    if(!$LNG->created) { $LNG->create(); }
    $args_count = func_num_args();
    if($args_count > 0 && $MTPS->Language != "") {
        $lng = $MTPS->Language;
        $id = func_get_arg(0);
        $pos = -1;
        for($aa=0; $aa<$LNG->urlCount; $aa++) {
            if($LNG->urlItems[$aa]->id == $id) { $pos = $aa; break; }}
        if($pos > -1) {
            if($args_count > 1) {
                $text = $LNG->urlItems[$pos]->text;
                for($aa=0; $aa<$args_count-1; $aa++) {
                    $str = sprintf("%%%d",$args_count-$aa-1);
                    $pos = $args_count-$aa-1;
                    $dynamic_text = func_get_arg($pos);
                    $text = str_replace($str,$dynamic_text,$text);}
                return $text;}
            return $LNG->urlItems[$pos]->text;}
        return "[!".$id."]";}
    return "[LNG_ERROR]";
}

LngAdd('urlCONTACTS_PIM','en',"contacts");
LngAdd('urlCONTACTS_PIM','cs',"kontakty");
$urlCONTACTS_PIM = $urlPIM.Lng('urlCONTACTS_PIM')."/";
LngAdd('urlTODAY','en',"today");
LngAdd('urlTODAY','cs',"dnes");
LngAdd('urlNEWITEM','en',"new-item");
LngAdd('urlNEWITEM','cs',"nova-polozka");
LngAdd('urlRECORD','en',"record");
LngAdd('urlRECORD','cs',"zaznam");
LngAdd('urlCONTACTS','en',"contacts");
LngAdd('urlCONTACTS','cs',"kontakty");
LngAdd('urlACADEMICTITLES','en',"academic-titles");
LngAdd('urlACADEMICTITLES','cs',"akademicke-tituly");
LngAdd('urlGENERAL','en',"general");
LngAdd('urlGENERAL','cs',"obecne");
LngAdd('urlSEARCH','en',"search");
LngAdd('urlSEARCH','cs',"vyhledavani");
LngAdd('urlBLOG','en',"blog");
LngAdd('urlBLOG','cs',"blog");
LngAdd('urlVLOG','en',"vlog");
LngAdd('urlVLOG','cs',"vlog");
LngAdd('urlESHOP','en',"eshop");
LngAdd('urlESHOP','cs',"eshop");
LngAdd('urlDOCUMENTS','en',"documents");
LngAdd('urlDOCUMENTS','cs',"dokumenty");
LngAdd('urlDEPARTMENT','en',"department");
if(ModuleEnabled('cityhall')) { $str = "odbor"; } else { $str = "oddeleni"; }
LngAdd('urlDEPARTMENT','cs',$str);
LngAdd('urlADD','en',"add");
LngAdd('urlADD','cs',"pridat");
LngAdd('urlEDIT','en',"edit");
LngAdd('urlEDIT','cs',"upravit");
LngAdd('urlREMOVE','en',"remove");
LngAdd('urlREMOVE','cs',"odstranit");
LngAdd('urlACTIVATE','en',"activate");
LngAdd('urlACTIVATE','cs',"aktivovat");
LngAdd('urlMOVE','en',"move");
LngAdd('urlMOVE','cs',"presunout");
LngAdd('urlRESTORE','en',"restore");
LngAdd('urlRESTORE','cs',"obnovit");
LngAdd('urlOFFICIALBOARD','en',"official-board");
LngAdd('urlOFFICIALBOARD','cs',"uredni-deska");
LngAdd('urlNEWS','en',"news");
LngAdd('urlNEWS','cs',"aktuality");
LngAdd('urlCATEGORIES','en',"categories");
LngAdd('urlCATEGORIES','cs',"kategorie");
LngAdd('urlHOMEPAGEBANNERS','en',"homepage-banners");
LngAdd('urlHOMEPAGEBANNERS','cs',"bannery-hlavni-stranky");
LngAdd('urlTVKRALUPY','cs',"tv-kralupy");
LngAdd('urlKRALUPSKYZPRAVODAJ','cs',"kralupsky-zpravodaj");
LngAdd('urlTASKSTORECORDS','en',"tasks-to-records");
LngAdd('urlTASKSTORECORDS','cs',"ukoly-na-zaznamy");
LngAdd('urlDEACTIVATEDACCOUNTS','en',"deactivated-accounts");
LngAdd('urlDEACTIVATEDACCOUNTS','cs',"deaktivovane-ucty");
LngAdd('urlPOLITICALPARTIES','en',"political-parties");
LngAdd('urlPOLITICALPARTIES','cs',"politicke-strany");
LngAdd('urlAGENDAS','en',"agendas");
LngAdd('urlAGENDAS','cs',"agendy");
LngAdd('urlLAYOUTS','en',"layouts");
LngAdd('urlLAYOUTS','cs',"layouty");
LngAdd('urlPLUGINS','en',"plugins");
LngAdd('urlPLUGINS','cs',"moduly");
LngAdd('urlSTATISTICS','en',"statistics");
LngAdd('urlSTATISTICS','cs',"statistiky");
LngAdd('urlDEPARTMENTS','en',"departments");
if(ModuleEnabled('cityhall')) { $str = "odbory"; } else { $str = "oddeleni"; }
LngAdd('urlDEPARTMENTS','cs',$str);
LngAdd('urlBUILDINGS','en',"buildings");
LngAdd('urlBUILDINGS','cs',"budovy");
LngAdd('urlPEOPLE','en',"people");
LngAdd('urlPEOPLE','cs',"lide");
LngAdd('urlAPPOINTMENTS','en',"appointments");
LngAdd('urlAPPOINTMENTS','cs',"udalosti");
LngAdd('urlEVENTS','en',"events");
LngAdd('urlEVENTS','cs',"akce");
LngAdd('urlABOUT_US','en',"about-us");
LngAdd('urlABOUT_US','cs',"o-nas");
LngAdd('urlSERVICES','en',"services");
LngAdd('urlSERVICES','cs',"sluzby");
LngAdd('urlOURTEAM','en',"our-team");
LngAdd('urlOURTEAM','cs',"nas-tym");
LngAdd('urlREFERENCES','en',"references");
LngAdd('urlREFERENCES','cs',"reference");
LngAdd('urlNEWCONTACT','en',"new-contact");
LngAdd('urlNEWCONTACT','cs',"novy-kontakt");
$urlNEWCONTACT = $urlCONTACTS_PIM.Lng('urlNEWCONTACT')."/";
LngAdd('urlCALENDAR_PIM','en',"calendar");
LngAdd('urlCALENDAR_PIM','cs',"kalendar");
$urlCALENDAR_PIM = $urlPIM.Lng('urlCALENDAR_PIM')."/";
LngAdd('urlCALENDAR','en',"calendar");
LngAdd('urlCALENDAR','cs',"kalendar");
LngAdd('urlDAY','en',"day");
LngAdd('urlDAY','cs',"den");
LngAdd('urlAGENDA','en',"agenda");
LngAdd('urlAGENDA','cs',"agenda");
LngAdd('urlWEEK','en',"week");
LngAdd('urlWEEK','cs',"tyden");
LngAdd('urlMONTH','en',"month");
LngAdd('urlMONTH','cs',"mesic");
LngAdd('urlEVENTS_PIM','en',"events");
LngAdd('urlEVENTS_PIM','cs',"udalosti");
$urlEVENTS_PIM = $urlPIM.Lng('urlEVENTS_PIM')."/";
LngAdd('urlTASKS','en',"tasks");
LngAdd('urlTASKS','cs',"ukoly");
$urlTASKS_PIM = $urlPIM.Lng('urlTASKS')."/";
LngAdd('urlNEWTASK','en',"new-task");
LngAdd('urlNEWTASK','cs',"novy-ukol");
$urlNEWTASK = $urlTASKS_PIM.Lng('urlNEWTASK')."/";
LngAdd('urlNOTES_PIM','en',"notes");
LngAdd('urlNOTES_PIM','cs',"poznamky");
$urlNOTES_PIM = $urlPIM.Lng('urlNOTES_PIM')."/";
LngAdd('urlNOTES','en',"notes");
LngAdd('urlNOTES','cs',"poznamky");
LngAdd('urlCALENDARS','en',"calendars");
LngAdd('urlCALENDARS','cs',"kalendare");
LngAdd('urlPROJECTS_PIM','en',"projects");
LngAdd('urlPROJECTS_PIM','cs',"projekty");
$urlPROJECTS_PIM = $urlPIM.Lng('urlPROJECTS_PIM')."/";
LngAdd('urlDIARY','en',"diary");
LngAdd('urlDIARY','cs',"denik");
$urlDIARY_PIM = $urlPIM.Lng('urlDIARY')."/";
LngAdd('urlMAIL','en',"mail");
LngAdd('urlMAIL','cs',"posta");
$urlMAIL_PIM = $urlPIM.Lng('urlMAIL')."/";
LngAdd('urlUSER','en',"user");
LngAdd('urlUSER','cs',"uzivatel");
$urlUSER = $urlWEB.Lng('urlUSER')."/";
$urlUSERSSL = $urlWEBSSL.Lng('urlUSER')."/";
$urlLOGIN = $urlUSER;
$urlLOGINSSL = $urlUSERSSL;
LngAdd('urlEMAILAUTH','en',"auth");
LngAdd('urlEMAILAUTH','cs',"autorizace");
$urlEMAILAUTH = $urlUSER.Lng('urlEMAILAUTH')."/";
LngAdd('urlBUYLICENSE','en',"buy-license");
LngAdd('urlBUYLICENSE','cs',"koupit-licenci");
$urlBUYLICENSE = $urlUSER.Lng('urlBUYLICENSE')."/";
LngAdd('urlLICENSEORDERS','en',"license-orders");
LngAdd('urlLICENSEORDERS','cs',"objednavky-licenci");
LngAdd('urlINVITEFRIENDS','en',"invite-friends");
LngAdd('urlINVITEFRIENDS','cs',"pozvat-pratele");
$urlINVITEFRIENDS = $urlUSER.Lng('urlINVITEFRIENDS')."/";
LngAdd('urlPASSCHANGE','en',"password-change");
LngAdd('urlPASSCHANGE','cs',"zmena-hesla");
$urlPASSCHANGE = $urlUSER.Lng('urlPASSCHANGE')."/";
LngAdd('urlTERMS','en',"terms-of-use");
LngAdd('urlTERMS','cs',"podminky-pouzivani");
$urlTERMS = $urlUSER.Lng('urlTERMS')."/";
LngAdd('urlARTICLES_ADMIN','en',"articles");
LngAdd('urlARTICLES_ADMIN','cs',"clanky");
$urlARTICLES_ADMIN = $urlADMIN.Lng('urlARTICLES_ADMIN')."/";
LngAdd('urlPAGES','en',"pages");
LngAdd('urlPAGES','cs',"stranky");
$urlPAGES = $urlADMIN.Lng('urlPAGES')."/";
LngAdd('urlGALLERY','en',"gallery");
LngAdd('urlGALLERY','cs',"galerie");
$urlGALLERY_ADMIN = $urlADMIN.Lng('urlGALLERY')."/";
LngAdd('urlCONTACTS_ADMIN','en',"contacts");
LngAdd('urlCONTACTS_ADMIN','cs',"kontakty");
$urlCONTACTS_ADMIN = $urlADMIN.Lng('urlCONTACTS_ADMIN')."/";
LngAdd('urlUSERS','en',"users");
LngAdd('urlUSERS','cs',"uzivatele");
LngAdd('urlINTRANET','en',"intranet");
LngAdd('urlINTRANET','cs',"intranet");
LngAdd('urlUSERS_ADMIN','en',"users");
LngAdd('urlUSERS_ADMIN','cs',"uzivatele");
$urlUSERS_ADMIN = $urlADMIN.Lng('urlUSERS_ADMIN')."/";
LngAdd('urlNEW_USER','en',"new-user");
LngAdd('urlNEW_USER','cs',"novy-uzivatel");
LngAdd('urlAFFILIATE','en',"affiliate");
LngAdd('urlAFFILIATE','cs',"affiliate");
LngAdd('urlEDIT_USER','en',"edit-user");
LngAdd('urlEDIT_USER','cs',"upravit-uzivatele");
LngAdd('urlRIGHTS','en',"rights");
LngAdd('urlRIGHTS','cs',"prava");
LngAdd('urlSETTINGS','en',"settings");
LngAdd('urlSETTINGS','cs',"nastaveni");
$urlSETTINGS_ADMIN = $urlADMIN.Lng('urlSETTINGS')."/";
LngAdd('urlFORGOTTENPASSWORD','en',"forgotten-password");
LngAdd('urlFORGOTTENPASSWORD','cs',"zapomenute-heslo");
$urlFORGOTTENPASSWORD = $urlUSER.Lng('urlFORGOTTENPASSWORD')."/";
LngAdd('urlNEWPASSWORD','en',"new-password");
LngAdd('urlNEWPASSWORD','cs',"nove-heslo");
$urlNEWPASSWORD = $urlUSER.Lng('urlNEWPASSWORD')."/";
LngAdd('urlNEWACCOUNT','en',"new-account");
LngAdd('urlNEWACCOUNT','cs',"novy-ucet");
$urlNEWACCOUNT = $urlUSER.Lng('urlNEWACCOUNT')."/";
LngAdd('Lng','en',$MTPS->Language);
LngAdd('Lng','cs',$MTPS->Language);
LngAdd('UnknownError','en',"Unknown error");
LngAdd('UnknownError','cs',"Neznámá chyba!");
LngAdd('Administration','en',"Administration");
LngAdd('Administration','cs',"Administrace");
LngAdd('EUDAdministration','en',"Official board administration");
LngAdd('EUDAdministration','cs',"Administrace úřední desky");
LngAdd('DocumentAdministration','en',"Document administration");
LngAdd('DocumentAdministration','cs',"Administrace dokumentu");
LngAdd('BackToAdministration','en',"Back to administration");
LngAdd('BackToAdministration','cs',"Zpět do administrace");
LngAdd('OfTheWeb','en',"of the web");
LngAdd('OfTheWeb','cs',"webu");
LngAdd('OfficialBoard','en',"Official board");
LngAdd('OfficialBoard','cs',"Úřední deska");
LngAdd('News','en',"News");
LngAdd('News','cs',"Aktuality");
LngAdd('NewsPinPos','en',"Pinned-news position");
LngAdd('NewsPinPos','cs',"Pozice připnuté aktuality");
LngAdd('NewsGroup','en',"News-group");
LngAdd('NewsGroup','cs',"Skupina aktualit");
LngAdd('IsEvent','en',"Is event to calendar");
LngAdd('IsEvent','cs',"Událost do kalendáře");
LngAdd('NewestNews','en',"Newest news");
LngAdd('NewestNews','cs',"Nejnovější aktuality");
LngAdd('NewsIcon','en',"News icon");
LngAdd('NewsIcon','cs',"Ikona aktuality");
LngAdd('LoadNextNews','en',"Load more news");
LngAdd('LoadNextNews','cs',"Načíst další aktuality");
LngAdd('PreviousNews','en',"Previous");
LngAdd('PreviousNews','cs',"Předchozí");
LngAdd('NextNews','en',"Next");
LngAdd('NextNews','cs',"Následující");
LngAdd('CreateNewsAndEditText','en',"Create news and edit text");
LngAdd('CreateNewsAndEditText','cs',"Vytvořit aktualitu a editovat text");
LngAdd('CreateArticleAndEditText','en',"Create article and edit text");
LngAdd('CreateArticleAndEditText','cs',"Vytvořit článek a editovat text");
LngAdd('CreateCalendarItemAndEditText','en',"Create calendar item and edit text");
LngAdd('CreateCalendarItemAndEditText','cs',"Vytvořit položku kalendáře a editovat text");
LngAdd('CalendarOfEventsInCityAndNeighbourhood','en',"Calendar of events in city and neighbourhood");
LngAdd('CalendarOfEventsInCityAndNeighbourhood','cs',"Kalendář událostí ve městě a okolí");
LngAdd('NewCalendarItem','en',"New calendar item");
LngAdd('NewCalendarItem','cs',"Nová položka kalendáře");
LngAdd('EditCalendarItem','en',"Edit calendar item");
LngAdd('EditCalendarItem','cs',"Upravit položku kalendáře");
LngAdd('NewVideo','en',"New video");
LngAdd('NewVideo','cs',"Nové video");
LngAdd('EditVideo','en',"Edit video");
LngAdd('EditVideo','cs',"Upravit video");
LngAdd('URL','en',"URL");
LngAdd('URL','cs',"URL");
LngAdd('URLName','en',"URL-name");
LngAdd('URLName','cs',"URL-název");
LngAdd('ArticleWithThisURLNameAlreadyExists','en',"Article with this URL-name already exists!");
LngAdd('ArticleWithThisURLNameAlreadyExists','cs',"Článek s tímto URL-názvem již existuje!");
LngAdd('Search','en',"Search");
LngAdd('Search','cs',"Vyhledávání");
LngAdd('ThisMessageWasSentToEmailAddress','en',"This message was sent to an e-mail address %1.");
LngAdd('ThisMessageWasSentToEmailAddress','cs',"Tato zpráva byla odeslána na e-mailovou adresu %1.");
LngAdd('ReadNews','cs',"Číst aktualitu");
LngAdd('ContinueReading','cs',"Pokračovat ve čtení");
LngAdd('ContinueReading','en',"Continue reading");
LngAdd('CountOfViews','en',"Count of views");
LngAdd('CountOfViews','cs',"Počet zobrazení");
LngAdd('InsertedBy','en',"Inserted by");
LngAdd('InsertedBy','cs',"Vložil(a)");
LngAdd('Date','en',"Date");
LngAdd('Date','cs',"Datum");
LngAdd('ReleaseDate','en',"Release date");
LngAdd('ReleaseDate','cs',"Datum vydání");
LngAdd('BroadcastDate','en',"Broadcast date");
LngAdd('BroadcastDate','cs',"Datum vysílání");
LngAdd('Place','en',"Place");
LngAdd('Place','cs',"Místo");
LngAdd('Placement','en',"Placement");
LngAdd('Placement','cs',"Umístění");
LngAdd('DateAndTime','en',"Date and time");
LngAdd('DateAndTime','cs',"Datum a čas");
LngAdd('ClockAlign','en',"Clock align");
LngAdd('ClockAlign','cs',"Zarovnání hodin");
LngAdd('ShownFinishedTasksMaxAge','en',"Shown finished tasks max age");
LngAdd('ShownFinishedTasksMaxAgen','cs',"Maximální stáří zobrazených dokončených úkolů");
LngAdd('Time','en',"Time");
LngAdd('Time','cs',"Čas");
LngAdd('Hours','en',"Hours");
LngAdd('Hours','cs',"Hodiny");
LngAdd('Minutes','en',"Minutes");
LngAdd('Minutes','cs',"Minuty");
LngAdd('Days','en',"Days");
LngAdd('Days','cs',"Dny");
LngAdd('Show','en',"Show");
LngAdd('Show','cs',"Zobrazit");
LngAdd('ShowFullText','en',"Show full text");
LngAdd('ShowFullText','cs',"Zobrazit celý text");
LngAdd('HideLongText','en',"Hide long text");
LngAdd('HideLongText','cs',"Skrýt dlouhý text");
LngAdd('Detail','en',"Detail");
LngAdd('Detail','cs',"Detail");
LngAdd('Schedule','en',"Schedule");
LngAdd('Schedule','cs',"Naplánovat");
LngAdd('RescheduleToTodayIfNotFinished','en',"Reschedule to Today if not finished");
LngAdd('RescheduleToTodayIfNotFinished','cs',"Při nesplnění přeplánovat na Dnes");
LngAdd('IfNotFinished','en',"If not finished");
LngAdd('IfNotFinished','cs',"Při nesplnění");
LngAdd('Finished','en',"Finished");
LngAdd('Finished','cs',"Dokončeno");
LngAdd('Recurrence','en',"Recurrence");
LngAdd('Recurrence','cs',"Opakování");
LngAdd('ScheduleNews','en',"Schedule news");
LngAdd('ScheduleNews','cs',"Naplánovat aktualitu");
LngAdd('NewNews','en',"New news");
LngAdd('NewNews','cs',"Nová aktualita");
LngAdd('EditNews','en',"Edit news");
LngAdd('EditNews','cs',"Upravit aktualitu");
LngAdd('AllNews','en',"All news");
LngAdd('AllNews','cs',"Všechny aktuality");
LngAdd('NewsInCategory','en',"News in category");
LngAdd('NewsInCategory','cs',"Aktuality v kategorii");
LngAdd('Article','en',"Article");
LngAdd('Article','cs',"Article");
LngAdd('WithoutTitle','en',"Without title");
LngAdd('WithoutTitle','cs',"Bez titulku");
LngAdd('ArticleTitle','en',"Article title");
LngAdd('ArticleTitle','cs',"Titulek článku");
LngAdd('TitleOfNewArticle','en',"Title of new article");
LngAdd('TitleOfNewArticle','cs',"Titulek nového článku");
LngAdd('WriteSomeArticleInsteadOfThisText','en',"Write some article instead of this text.");
LngAdd('WriteSomeArticleInsteadOfThisText','cs',"Místo tohoto textu napište nějaký článek.");
LngAdd('ReadArticle','en',"Read article");
LngAdd('ReadArticle','cs',"Číst článek");
LngAdd('NewArticle','en',"New article");
LngAdd('NewArticle','cs',"Nový článek");
LngAdd('EditArticle','en',"Edit article");
LngAdd('EditArticle','cs',"Upravit článek");
LngAdd('EditArticleTitle','en',"Edit article title");
LngAdd('EditArticleTitle','cs',"Upravit titulek článku");
LngAdd('PublishArticle','en',"Publish article");
LngAdd('PublishArticle','cs',"Publikovat článek");
LngAdd('DeleteArticle','en',"Delete article");
LngAdd('DeleteArticle','cs',"Smazat článek");
LngAdd('ContainsUnsupportedCharsOrDoubledSpaces','en',"contains unsupported characters or doubed spaces.");
LngAdd('ContainsUnsupportedCharsOrDoubledSpaces','cs',"obsahuje nepodporované znaky nebo zdvojené mezery.");
LngAdd('Image','en',"Image");
LngAdd('Image','cs',"Obrázek");
LngAdd('Messages','en',"Messages");
LngAdd('Messages','cs',"Zprávy");
LngAdd('Profile','en',"Profile");
LngAdd('Profile','cs',"Profil");
LngAdd('UsersProfile','en',"User's profile");
LngAdd('UsersProfile','cs',"Uživatelův profil");
LngAdd('Me','en',"Me");
LngAdd('Me','cs',"Já");
LngAdd('MyProfile','en',"My profile");
LngAdd('MyProfile','cs',"Můj profil");
LngAdd('ChangeProfilePicture','en',"Change profile picture");
LngAdd('ChangeProfilePicture','cs',"Změnit profilový obrázek");
LngAdd('SetProfileUsername','en',"Set profile username");
LngAdd('SetProfileUsername','cs',"Nastavit uživatelské jméno profilu");
LngAdd('SetUsername','en',"Set username");
LngAdd('SetUsername','cs',"Nastavit uživatelské jméno");
LngAdd('UsernameIsTaken','en',"Username is taken");
LngAdd('UsernameIsTaken','cs',"Uživatelské jméno je již zabrané");
LngAdd('ChangeCalendarIcon','en',"Change calendar's icon");
LngAdd('ChangeCalendarIcon','cs',"Změnit ikonu kalendáře");
LngAdd('Preview','en',"Preview");
LngAdd('Preview','cs',"Náhled");
LngAdd('Album','en',"Album");
LngAdd('Album','cs',"Album");
LngAdd('AddAlbumToHomepage','en',"Add album to homepage");
LngAdd('AddAlbumToHomepage','cs',"Přidat album na hlavní stránku");
LngAdd('Visibility','en',"Visibility");
LngAdd('Visibility','cs',"Viditelnost");
LngAdd('RecordVisibilitySettings','en',"Record visibility settings");
LngAdd('RecordVisibilitySettings','cs',"Nastavení viditelnosti záznamu");
LngAdd('RecordSharingSettings','en',"Record Sharing settings");
LngAdd('RecordSharingSettings','cs',"Nastavení sdílení záznamu");
LngAdd('Privacy','en',"Privacy");
LngAdd('Privacy','cs',"Soukromí");
LngAdd('AllAlbums','en',"All albums");
LngAdd('AllAlbums','cs',"Všechna alba");
LngAdd('Document','en',"Document");
LngAdd('Document','cs',"Dokument");
LngAdd('AddDocument','en',"Add document");
LngAdd('AddDocument','cs',"Přidat dokument");
LngAdd('AddImage','en',"Add image");
LngAdd('AddImage','cs',"Přidat obrázek");
LngAdd('EditImage','en',"Edit image");
LngAdd('EditImage','cs',"Upravit obrázek");
LngAdd('NewAlbum','en',"New album");
LngAdd('NewAlbum','cs',"Nové album");
LngAdd('RenameAlbum','en',"Rename album");
LngAdd('RenameAlbum','cs',"Přejmenovat album");
LngAdd('EditAlbum','en',"Edit album");
LngAdd('EditAlbum','cs',"Upravit album");
LngAdd('DeleteAlbum','en',"Delete album");
LngAdd('DeleteAlbum','cs',"Vymazat album");
LngAdd('DeleteImage','en',"Delete image");
LngAdd('DeleteImage','cs',"Vymazat obrázek");
LngAdd('DeleteCalendarItem','en',"Delete calendar item");
LngAdd('DeleteCalendarItem','cs',"Vymazat položku kalendáře");
LngAdd('DeleteOrganizer','en',"Delete organizer");
LngAdd('DeleteOrganizer','cs',"Vymazat organizér");
LngAdd('CalendarItemIcon','en',"Calendar item icon");
LngAdd('CalendarItemIcon','cs',"Ikona položky kalendáře");
LngAdd('DeleteNews','en',"Delete news");
LngAdd('DeleteNews','cs',"Vymazat aktualitu");
LngAdd('Category','en',"Category");
LngAdd('Category','cs',"Kategorie");
LngAdd('DateOfPublication','en',"Date of publication");
LngAdd('DateOfPublication','cs',"Datum zveřejnění");
LngAdd('TimeOfPublication','en',"Time of publication");
LngAdd('TimeOfPublication','cs',"Čas zveřejnění");
LngAdd('Text','en',"Text");
LngAdd('Text','cs',"Text");
LngAdd('EditText','en',"Edit text");
LngAdd('EditText','cs',"Upravit text");
LngAdd('Name','en',"Name");
LngAdd('Name','cs',"Jméno");
LngAdd('Upcoming','en',"Upcoming");
LngAdd('Upcoming','cs',"Nadcházející");
LngAdd('NoUpcomingEvent','en',"No upcoming event");
LngAdd('NoUpcomingEvent','cs',"Žádná nadcházející událost");
LngAdd('Attachments','en',"Attachments");
LngAdd('Attachments','cs',"Přílohy");
LngAdd('Attachment','en',"Attachment");
LngAdd('Attachment','cs',"Příloha");
LngAdd('AttachmentFile','en',"Attachment file");
LngAdd('AttachmentFile','cs',"Soubor přílohy");
LngAdd('AddAttachment','en',"Add attachment");
LngAdd('AddAttachment','cs',"Přidat přílohu");
LngAdd('AddDocumentToDownload','en',"Add document to download");
LngAdd('AddDocumentToDownload','cs',"Přidat dokument ke stažení");
LngAdd('MorePages','en',"More pages");
LngAdd('MorePages','cs',"Další stránky");
LngAdd('SuperiorPage','en',"Superior page");
LngAdd('SuperiorPage','cs',"Nadřazená stránka");
LngAdd('RenamePage','en',"Rename page");
LngAdd('RenamePage','cs',"Přejmenovat stránku");
LngAdd('EditTiles','en',"Edit tiles");
LngAdd('EditTiles','cs',"Upravit dlaždice");
LngAdd('Tiles','en',"Tiles");
LngAdd('Tiles','cs',"Dlaždice");
LngAdd('NewTile','en',"New tile");
LngAdd('NewTile','cs',"Nová dlaždice");
LngAdd('Icon','en',"Icon");
LngAdd('Icon','cs',"Ikona");
LngAdd('AddNewNews','en',"Add new news");
LngAdd('AddNewNews','cs',"Přidat novou aktualitu");
LngAdd('Documents','en',"Documents");
LngAdd('Documents','cs',"Dokumenty");
LngAdd('Tools','en',"Tools");
LngAdd('Tools','cs',"Nástroje");
LngAdd('DocumentType','en',"Document type");
LngAdd('DocumentType','cs',"Typ dokumentu");
LngAdd('NewDocument','en',"New document");
LngAdd('NewDocument','cs',"Nový dokument");
LngAdd('EditDocument','en',"Edit document");
LngAdd('EditDocument','cs',"Upravit dokument");
LngAdd('AllDocuments','en',"All documents");
LngAdd('AllDocuments','cs',"Všechny dokumenty");
LngAdd('Refresh','en',"Refresh");
LngAdd('Refresh','cs',"Obnovit");
LngAdd('GoToToday','en',"Go to Today");
LngAdd('GoToToday','cs',"Přejít na Dnes");
LngAdd('GoToPrevious','en',"Go to previous");
LngAdd('GoToPrevious','cs',"Přejít na předchozí");
LngAdd('GoToNext','en',"Go to next");
LngAdd('GoToNext','cs',"Přejít na následující");
LngAdd('toOfficialBoard','en',"to official board");
LngAdd('toOfficialBoard','cs',"na úřední desku");
LngAdd('onOfficialBoard','en',"on official board");
LngAdd('onOfficialBoard','cs',"na úřední desce");
LngAdd('NewsCategories','en',"News categories");
LngAdd('NewsCategories','cs',"Kategorie aktualit");
LngAdd('EditCategories','en',"Edit categories");
LngAdd('EditCategories','cs',"Upravit kategorie");
LngAdd('NewCategory','en',"New category");
LngAdd('NewCategory','cs',"Nová kategorie");
LngAdd('Categories','en',"Categories");
LngAdd('Categories','cs',"Kategorie");
LngAdd('RenameCategory','en',"Rename category");
LngAdd('RenameCategory','cs',"Přejmenovat kategorii");
LngAdd('EditCategory','en',"Edit category");
LngAdd('EditCategory','cs',"Upravit kategorii");
LngAdd('DeleteCategory','en',"Delete category");
LngAdd('DeleteCategory','cs',"Smazat kategorii");
LngAdd('ArrangeCategories','en',"Arrange categories");
LngAdd('ArrangeCategories','cs',"Uspořádat kategorie");
LngAdd('MainPage','en',"Main page");
LngAdd('MainPage','cs',"Hlavní stránka");
LngAdd('HomepageBanners','en',"Homepage banners");
LngAdd('HomepageBanners','cs',"Bannery hlavní stránky");
LngAdd('TVKralupy','cs',"TV Kralupy");
LngAdd('KralupskyZpravodaj','cs',"Kralupský zpravodaj");
LngAdd('Organizer','en',"Organizer");
LngAdd('Organizer','cs',"Organizér");
LngAdd('Desktop','en',"Desktop");
LngAdd('Desktop','cs',"Plocha");
LngAdd('SpravceCasu','en',"Správce času");
LngAdd('SpravceCasu','cs',"Správce času");
LngAdd('Calendar','en',"Calendar");
LngAdd('Calendar','cs',"Kalendář");
LngAdd('Tasks','en',"Tasks");
LngAdd('Tasks','cs',"Úkoly");
LngAdd('Anniversaries','en',"Anniversaries");
LngAdd('Anniversaries','cs',"Výročí");
LngAdd('BirthdaysAndAnniversaries','en',"Birthdays and anniversaries");
LngAdd('BirthdaysAndAnniversaries','cs',"Narozeniny a výročí");
LngAdd('Reminders','en',"Reminders");
LngAdd('Reminders','cs',"Upomínky");
LngAdd('Question','en',"Question");
LngAdd('Question','cs',"Dotaz");
LngAdd('Alerts','en',"Alerts");
LngAdd('Alerts','cs',"Upozornění");
LngAdd('AlertType','en',"Alert type");
LngAdd('AlertType','cs',"Typ upozornění");
LngAdd('NoAlert','en',"No alert");
LngAdd('NoAlert','cs',"Žádné upozornění");
LngAdd('SetAlert','en',"Set alert");
LngAdd('SetAlert','cs',"Nastavit upozornění");
LngAdd('ShowAndFinishAlert','en',"Show and finish alert");
LngAdd('ShowAndFinishAlert','cs',"Zobrazit a ukončit upozornění");
LngAdd('FinishAlert','en',"Finish alert");
LngAdd('FinishAlert','cs',"Ukončit upozornění");
LngAdd('Appointments','en',"Appointments");
LngAdd('Appointments','cs',"Události");
LngAdd('Meetings','en',"Meetings");
LngAdd('Meetings','cs',"Schůzky");
LngAdd('ScheduleTask','en',"Schedule task");
LngAdd('ScheduleTask','cs',"Naplánovat úkol");
LngAdd('Beginning','en',"Beginning");
LngAdd('Beginning','cs',"Začátek");
LngAdd('End','en',"End");
LngAdd('End','cs',"Konec");
LngAdd('From','en',"From");
LngAdd('From','cs',"Od");
LngAdd('To','en',"To");
LngAdd('To','cs',"Do");
LngAdd('SetDateAndTime','en',"Set date and time");
LngAdd('SetDateAndTime','cs',"Nastavit datum a čas");
LngAdd('SetDate','en',"Set date");
LngAdd('SetDate','cs',"Nastavit datum");
LngAdd('AddTime','en',"Add time");
LngAdd('AddTime','cs',"Přidat čas");
LngAdd('ScheduledTasks','en',"Scheduled tasks");
LngAdd('ScheduledTasks','cs',"Naplánované úkoly");
LngAdd('Scheduled','en',"Scheduled");
LngAdd('Scheduled','cs',"Naplánováno");
LngAdd('AllTasks','en',"All tasks");
LngAdd('AllTasks','cs',"Všechny úkoly");
LngAdd('AllNotes','en',"All notes");
LngAdd('AllNotes','cs',"Všechny poznámky");
LngAdd('ImportantTasks','en',"Important tasks");
LngAdd('ImportantTasks','cs',"Důležité úkoly");
LngAdd('DeleteFinishedTasks','en',"Delete finished tasks");
LngAdd('DeleteFinishedTasks','cs',"Vymazat dokončené úkoly");
LngAdd('HiddenTask','en',"Hidden task");
LngAdd('HiddenTask','cs',"Skrytý úkol");
LngAdd('ShowHiddenTasks','en',"Show hidden tasks");
LngAdd('ShowHiddenTasks','cs',"Zobrazit skryté úkoly");
LngAdd('HideHiddenTasks','en',"Hide hidden tasks");
LngAdd('HideHiddenTasks','cs',"Skrýt skryté úkoly");
LngAdd('DeleteTask','en',"Delete task");
LngAdd('DeleteTask','cs',"Vymazat úkol");
LngAdd('DeleteNote','en',"Delete note");
LngAdd('DeleteNote','cs',"Vymazat poznámku");
LngAdd('DeleteRecord','en',"Delete record");
LngAdd('DeleteRecord','cs',"Vymazat záznam");
LngAdd('NoRecordSelected','en',"No record selected!");
LngAdd('NoRecordSelected','cs',"Není vybrán žádný záznam!");
LngAdd('NoContactSelected','en',"No contact selected!");
LngAdd('NoContactSelected','cs',"Není vybrán žádný kontakt!");
LngAdd('NoItemSelected','en',"No item selected!");
LngAdd('NoItemSelected','cs',"Není vybrána žádná položka!");
LngAdd('DeleteVideo','en',"Delete video");
LngAdd('DeleteVideo','cs',"Vymazat video");
LngAdd('NoVideoSelected','en',"No video selected!");
LngAdd('NoVideoSelected','cs',"Není vybráno žádné video!");
LngAdd('TasksLists','en',"Tasks lists");
LngAdd('TasksLists','cs',"Seznamy úkolů");
LngAdd('TaskList','en',"Tasks list");
LngAdd('TaskList','cs',"Seznam úkolů");
LngAdd('Projects','en',"Projects");
LngAdd('Projects','cs',"Projekty");
LngAdd('Notes','en',"Notes");
LngAdd('Notes','cs',"Poznámky");
LngAdd('Calendars','en',"Calendars");
LngAdd('Calendars','cs',"Kalendáře");
LngAdd('Ongoing','en',"Ongoing");
LngAdd('Ongoing','cs',"Probíhající");
LngAdd('Print','en',"Print");
LngAdd('Print','cs',"Tisk");
LngAdd('PrintToPDF','en',"Print to PDF");
LngAdd('PrintToPDF','cs',"Vytisknout do PDF");
LngAdd('AllCalendars','en',"All calendars");
LngAdd('AllCalendars','cs',"Všechny kalendáře");
LngAdd('NewCalendar','en',"New calendar");
LngAdd('NewCalendar','cs',"Nový kalendář");
LngAdd('SharedCalendars','en',"Shared calendars");
LngAdd('SharedCalendars','cs',"Sdílené kalendáře");
LngAdd('SharedCalendar','en',"Shared calendar");
LngAdd('SharedCalendar','cs',"Sdílený kalendář");
LngAdd('NewSharedCalendar','en',"New shared calendar");
LngAdd('NewSharedCalendar','cs',"Nový sdílený kalendář");
LngAdd('EditSharedCalendar','en',"Edit shared calendar");
LngAdd('EditSharedCalendar','cs',"Upravit sdílený kalendář");
LngAdd('EditCalendar','en',"Edit calendar");
LngAdd('EditCalendar','cs',"Upravit kalendář");
LngAdd('Diary','en',"Diary");
LngAdd('Diary','cs',"Deník");
LngAdd('Mail','en',"Mail");
LngAdd('Mail','cs',"Pošta");
LngAdd('Articles','en',"Articles");
LngAdd('Articles','cs',"Články");
LngAdd('ThereAreNoArticlesHere','en',"There are no articles here.");
LngAdd('ThereAreNoArticlesHere','cs',"Zde nejsou žádné články.");
LngAdd('ArticlesNotYetPublished','en',"Articles not yet published");
LngAdd('ArticlesNotYetPublished','cs',"Zatím nepublikované články");
LngAdd('Pages','en',"Pages");
LngAdd('Pages','cs',"Stránky");
LngAdd('Blog','en',"Blog");
LngAdd('Blog','cs',"Blog");
LngAdd('Gallery','en',"Gallery");
LngAdd('Gallery','cs',"Galerie");
LngAdd('Contacts','en',"Contacts");
LngAdd('Contacts','cs',"Kontakty");
LngAdd('Groups','en',"Groups");
LngAdd('Groups','cs',"Skupiny");
LngAdd('ItemXAlreadyExists','en',"Item \"%1\" already exists!");
LngAdd('ItemXAlreadyExists','cs',"Položka \"%1\" již existuje!");
LngAdd('EditContact','en',"Edit contact");
LngAdd('EditContact','cs',"Upravit kontakt");
LngAdd('EditContactsGroup','en',"Edit contacts group");
LngAdd('EditContactsGroup','cs',"Upravit skupinu kontaktů");
LngAdd('NewContactsGroup','en',"New contacts group");
LngAdd('NewContactsGroup','cs',"Nová skupina kontaktů");
LngAdd('NewGroup','en',"New group");
LngAdd('NewGroup','cs',"Nová skupina");
LngAdd('ContactsGroupsOptions','en',"Contacts groups options");
LngAdd('ContactsGroupsOptions','cs',"Možnosti skupin kontaktů");
LngAdd('AssignContactToThisGroups','en',"Assign contact to this groups");
LngAdd('AssignContactToThisGroups','cs',"Zařadit kontakt do těchto skupin");
LngAdd('ContactsGroups','en',"Contacts groups");
LngAdd('ContactsGroups','cs',"Skupiny kontaktů");
LngAdd('AllContactsGroups','en',"All contacts groups");
LngAdd('AllContactsGroups','cs',"Všechny skupiny kontaktů");
LngAdd('DisplayedContactsGroups','en',"Displayed contacts groups");
LngAdd('DisplayedContactsGroups','cs',"Zobrazené skupiny kontaktů");
LngAdd('NoResultsFound','en',"No results found");
LngAdd('NoResultsFound','cs',"Žádné výsledky nenalezeny");
LngAdd('TotalResultsFound','en',"Total results found: %1");
LngAdd('TotalResultsFound','cs',"Celkem nalezených výsledků: %1");
LngAdd('WithoutGroup','en',"Without group");
LngAdd('WithoutGroup','cs',"Bez skupiny");
LngAdd('AllContacts','en',"All contacts");
LngAdd('AllContacts','cs',"Všechny kontakty");
LngAdd('AddContact','en',"Add contact");
LngAdd('AddContact','cs',"Přidat kontakt");
LngAdd('SearchForUser','en',"Search for user");
LngAdd('SearchForUser','cs',"Vyhledat uživatele");
LngAdd('People','en',"People");
LngAdd('People','cs',"Lidé");
LngAdd('Events','en',"Events");
LngAdd('Events','cs',"Akce");
LngAdd('Notifications','en',"Notifications");
LngAdd('Notifications','cs',"Upozornění");
LngAdd('YouHaveNoNotifications','en',"You have no notifications");
LngAdd('YouHaveNoNotifications','cs',"Nemáte žádná upozornění");
LngAdd('IgnoreRequest','en',"Ignore request");
LngAdd('IgnoreRequest','cs',"Ignorovat žádost");
LngAdd('AddUserToMyContacts','en',"Add user to my contacts");
LngAdd('AddUserToMyContacts','cs',"Přidat uživatele do mých kontaktů");
LngAdd('SendContactRequest','en',"Send contact request");
LngAdd('SendContactRequest','cs',"Odeslat požadavek k přidání do kontaktů");
LngAdd('ContactRequest','en',"Contact request");
LngAdd('ContactRequest','cs',"Požadavek kontaktu");
LngAdd('ContactRequestSent','en',"Contact request sent");
LngAdd('ContactRequestSent','cs',"Požadavek k přidání do kontaktů odeslán");
LngAdd('SocialEvents','en',"Social events");
LngAdd('SocialEvents','cs',"Společenské události");
LngAdd('EventType','en',"Event type");
LngAdd('EventType','cs',"Typ akce");
LngAdd('AddEventType','en',"Add event type");
LngAdd('AddEventType','cs',"Přidat typ akce");
LngAdd('RecordStatus','en',"Status");
LngAdd('RecordStatus','cs',"Stav");
LngAdd('EditEventType','en',"Edit event type");
LngAdd('EditEventType','cs',"Upravit typ akce");
LngAdd('LngStringOfTitle','en',"Lng string of Title");
LngAdd('LngStringOfTitle','cs',"Lng řetězec Popisu");
LngAdd('AboutUs','en',"About us");
LngAdd('AboutUs','cs',"O nás");
LngAdd('Services','en',"Services");
LngAdd('Services','cs',"Služby");
LngAdd('OurTeam','en',"Our team");
LngAdd('OurTeam','cs',"Náš tým");
LngAdd('References','en',"References");
LngAdd('References','cs',"Reference");
LngAdd('Users','en',"Users");
LngAdd('Users','cs',"Uživatelé");
LngAdd('Error','en',"Error");
LngAdd('Error','cs',"Chyba");
LngAdd('InputValuesError','en',"Input values error!");
LngAdd('InputValuesError','cs',"Chyba vstupních hodnot!");
LngAdd('Author','en',"Author");
LngAdd('Author','cs',"Autor");
LngAdd('InsertedBy-Unisex-','en',"Inserted by");
LngAdd('InsertedBy-Unisex-','cs',"Vložil(a)");
LngAdd('TasksToRecords','en',"Tasks to records");
LngAdd('TasksToRecords','cs',"Úkoly na Záznamy");
LngAdd('Tag','en',"Tag");
LngAdd('Tag','cs',"Štítek");
LngAdd('NewTag','en',"New tag");
LngAdd('NewTag','cs',"Nový štítek");
LngAdd('EditTag','en',"Edit tag");
LngAdd('EditTag','cs',"Upravit štítek");
LngAdd('DeleteTag','en',"Delete tag");
LngAdd('DeleteTag','cs',"Smazat štítek");
LngAdd('ThisTagCantBeDeleted','en',"This tag can't be deleted.");
LngAdd('ThisTagCantBeDeleted','cs',"Tento štítek nemůže být smazán.");
LngAdd('TagIsNotEmptyItCantBeDeleted','en',"Tag is not empty. It can't be deleted.");
LngAdd('TagIsNotEmptyItCantBeDeleted','cs',"Štítek není prázdný. Nemůže být vymazán.");
LngAdd('Tags','en',"Tags");
LngAdd('Tags','cs',"Štítky");
LngAdd('WithoutTag','en',"Without tag");
LngAdd('WithoutTag','cs',"Bez štítku");
LngAdd('AddNewTag','en',"Add new tag");
LngAdd('AddNewTag','cs',"Přidat nový štítek");
LngAdd('DeactivatedAccounts','en',"Deactivated accounts");
LngAdd('DeactivatedAccounts','cs',"Deaktivované účty");
LngAdd('DeactivateMyUserAccount','en',"Deactivate my user account");
LngAdd('DeactivateMyUserAccount','cs',"Deaktivovat můj uživatelský účet");
LngAdd('DeleteMyUserAccount','en',"Delete my user account");
LngAdd('DeleteMyUserAccount','cs',"Smazat můj uživatelský účet");
LngAdd('Deactivated','en',"Deactivated");
LngAdd('Deactivated','cs',"Deaktivováno");
LngAdd('Settings','en',"Settings");
LngAdd('Settings','cs',"Nastavení");
LngAdd('Properties','en',"Properties");
LngAdd('Properties','cs',"Vlastnosti");
LngAdd('TheLock','en',"The lock");
LngAdd('TheLock','cs',"Zámek");
LngAdd('MainMenu','en',"Main menu");
LngAdd('MainMenu','cs',"Hlavní menu");
LngAdd('PageSettings','en',"Page settings");
LngAdd('PageSettings','cs',"Nastavení stránky");
LngAdd('PageType','en',"Page type");
LngAdd('PageType','cs',"Typ stránky");
LngAdd('RedirectTo','en',"Redirect to");
LngAdd('RedirectTo','cs',"Přesměrovat na");
LngAdd('Fax','en',"Fax");
LngAdd('Fax','cs',"Fax");
LngAdd('Web','en',"Web");
LngAdd('Web','cs',"Web");
LngAdd('InstitutionCategory','en',"Institution category");
LngAdd('InstitutionCategory','cs',"Kategorie institucí");
LngAdd('InstitutionsCategories','en',"Institutions categories");
LngAdd('InstitutionsCategories','cs',"Kategorie institucí");
LngAdd('Institutions','en',"Institutions");
LngAdd('Institutions','cs',"Instituce");
LngAdd('NewInstitution','en',"New institution");
LngAdd('NewInstitution','cs',"Nová instituce");
LngAdd('EditInstitution','en',"Edit institution");
LngAdd('EditInstitution','cs',"Upravit instituci");
LngAdd('AllCategories','en',"All institutions");
LngAdd('AllCategories','cs',"Všechny instituce");
LngAdd('ShowSubpages','en',"Show subpages");
LngAdd('ShowSubpages','cs',"Zobrazit podstránky");
LngAdd('ShowAttachments','en',"Show attachments");
LngAdd('ShowAttachments','cs',"Zobrazit přílohy");
LngAdd('PageTitle','en',"Page title");
LngAdd('PageTitle','cs',"Titulek stránky");
LngAdd('Leave','en',"Leave");
LngAdd('Leave','cs',"Odejít");
LngAdd('Logout','en',"Logout");
LngAdd('Logout','cs',"Odhlásit");
LngAdd('PasswordChange','en',"Password change");
LngAdd('PasswordChange','cs',"Změna hesla");
LngAdd('YourPassword','en',"Your password");
LngAdd('YourPassword','cs',"Vaše heslo");
LngAdd('MainWebPage','en',"Main web page");
LngAdd('MainWebPage','cs',"Hlavní stránka webu");
LngAdd('Homepage','en',"Homepage");
LngAdd('Homepage','cs',"Hlavní stránka");
LngAdd('Importance','en',"Importance");
LngAdd('Importance','cs',"Důležitost");
LngAdd('RecordImportanceSettings','en',"Record-importance settings");
LngAdd('RecordImportanceSettings','cs',"Nastavení důležitosti záznamu");
LngAdd('Unimportant','en',"Unimportant");
LngAdd('Unimportant','cs',"Nedůležité");
LngAdd('Normal','en',"Normal");
LngAdd('Normal','cs',"Normální");
LngAdd('Important','en',"Important");
LngAdd('Important','cs',"Důležité");
LngAdd('NotifyConstantly','en',"NotifyConstantly");
LngAdd('NotifyConstantly','cs',"Upozorňovat neustále");
LngAdd('Urgent','en',"Urgent");
LngAdd('Urgent','cs',"Urgentní");
LngAdd('InfoAboutProject','en',"Info about project");
LngAdd('InfoAboutProject','cs',"Informace o projektu");
LngAdd('Sharing','en',"Sharing");
LngAdd('Sharing','cs',"Sdílení");
LngAdd('ShareWith','en',"Share with");
LngAdd('ShareWith','cs',"Sdílet s");
LngAdd('YouHaveNoContactsGroups','en',"You have no contact groups");
LngAdd('YouHaveNoContactsGroups','cs',"Nemáte žádné skupiny kontaktů");
LngAdd('YouHaveNoContacts','en',"You have no contact");
LngAdd('YouHaveNoContacts','cs',"Nemáte žádné kontakty");
LngAdd('OnlyMe','en',"Only me");
LngAdd('OnlyMe','cs',"Pouze já");
LngAdd('Me+Invited','en',"Me + Invited");
LngAdd('Me+Invited','cs',"Já + pozvaní");
LngAdd('Invited','en',"Invited");
LngAdd('Invited','cs',"Pozvaní");
LngAdd('InvitationSent','en',"Invitation sent");
LngAdd('InvitationSent','cs',"Pozvánka odeslána");
LngAdd('Invite','en',"Invite");
LngAdd('Invite','cs',"Pozvat");
LngAdd('MyContacts','en',"My contacts");
LngAdd('MyContacts','cs',"Mé kontakty");
LngAdd('Subscribers','en',"Subscribers");
LngAdd('Subscribers','cs',"Odběratelé");
LngAdd('InviteUsers','en',"Invite users");
LngAdd('InviteUsers','cs',"Pozvat uživatele");
LngAdd('CalendarSubscribers','en',"Calendar subscribers");
LngAdd('CalendarSubscribers','cs',"Odběratelé kalendáře");
LngAdd('Public','en',"Public");
LngAdd('Public','cs',"Veřejné");
LngAdd('SelectManually','en',"Select manually");
LngAdd('SelectManually','cs',"Vybrat ručně");
LngAdd('MyAccount','en',"My account");
LngAdd('MyAccount','cs',"Můj účet");
LngAdd('YouHaveNoRightsToDoThis','en',"You have no rights to do this.");
LngAdd('YouHaveNoRightsToDoThis','cs',"K tomuto nemáte dostatečná oprávnění.");
LngAdd('YouHaveNoRightsToEditThisItem','en',"You have no rights to edit this item.");
LngAdd('YouHaveNoRightsToEditThisItem','cs',"K úpravě této položky nemáte dostatečná oprávnění.");
LngAdd('YouHaveNoRightsToCreateOrEditUserAccount','en',"You have no rights to create or edit user account.");
LngAdd('YouHaveNoRightsToCreateOrEditUserAccount','cs',"Nemáte oprávnění vytvářet nebo upravovat uživatelský účet.");
LngAdd('YouHaveNoRightsToCreateOrEditAdminAccount','en',"You have no rights to create or edit administrator account.");
LngAdd('YouHaveNoRightsToCreateOrEditAdminAccount','cs',"Nemáte oprávnění vytvářet nebo upravovat administrátorský účet.");
LngAdd('SendEmailToUserAboutNewAccount','en',"Send e-mail to user about the new account");
LngAdd('SendEmailToUserAboutNewAccount','cs',"Poslat uživateli e-mail o novém účtu");
LngAdd('SetDefaultUserAccountPassword','en',"Set default user-account password");
LngAdd('SetDefaultUserAccountPassword','cs',"Nastavit uživatelskému účtu výchozí heslo");
LngAdd('NewBuilding','en',"New building");
LngAdd('NewBuilding','cs',"Nová budova");
LngAdd('Building','en',"Building");
LngAdd('Building','cs',"Budova");
LngAdd('EditBuilding','en',"Edit building");
LngAdd('EditBuilding','cs',"Upravit budovu");
LngAdd('BasicProfileSettings','en',"Basic profile settings");
LngAdd('BasicProfileSettings','cs',"Základní nastavení profilu");
LngAdd('DisplayMobileVersion','en',"Display mobile version");
LngAdd('DisplayMobileVersion','cs',"Zobrazit mobilní verzi");
LngAdd('DisplayVersionForDesktop','en',"Display version for desktop");
LngAdd('DisplayVersionForDesktop','cs',"Zobrazit verzi pro desktop");
LngAdd('NewPage','en',"New page");
LngAdd('NewPage','cs',"Nová stránka");
LngAdd('EditPage','en',"Edit page");
LngAdd('EditPage','cs',"Upravit stránku");
LngAdd('ExitTextEditation','en',"Exit text editation");
LngAdd('ExitTextEditation','cs',"Ukončit úpravu textu");
LngAdd('EditThisPage','en',"Edit this page");
LngAdd('EditThisPage','cs',"Upravit tuto stránku");
LngAdd('EditPagesText','en',"Edit page's text");
LngAdd('EditPagesText','cs',"Upravit text stránky");
LngAdd('EditNewsText','en',"Edit news text");
LngAdd('EditNewsText','cs',"Upravit text aktuality");
LngAdd('NewsTitleAndSettings','en',"News title and settings");
LngAdd('NewsTitleAndSettings','cs',"Titulek aktuality a nastavení");
LngAdd('TitleAndSettings','en',"Title and settings");
LngAdd('TitleAndSettings','cs',"Titulek a nastavení");
LngAdd('GoToTheNewsAdministration','en',"Go to the news administration");
LngAdd('GoToTheNewsAdministration','cs',"Přejít do administrace aktualit");
LngAdd('OnlyAdminCanCreateNewAccount','en',"Only administrator can create new accounts!");
LngAdd('OnlyAdminCanCreateNewAccount','cs',"Pouze administrátor může vytvářet nové účty!");
LngAdd('EditThisNews','en',"Edit this news");
LngAdd('EditThisNews','cs',"Upravit tuto aktualitu");
LngAdd('WebStructureAndPages','en',"Pages and web-structure");
LngAdd('WebStructureAndPages','cs',"Stránky a struktura webu");
LngAdd('ItemDoesntExist','en',"Item doesn't exist!");
LngAdd('ItemDoesntExist','cs',"Položka neexistuje!");
LngAdd('FileDoesntExist','en',"File doesn't exist!");
LngAdd('FileDoesntExist','cs',"Soubor neexistuje!");
LngAdd('PageDoesntExist','en',"Page doesn't exist!");
LngAdd('PageDoesntExist','cs',"Stránka neexistuje!");
LngAdd('CalendarDoesntExist','en',"Calendar doesn't exist!");
LngAdd('CalendarDoesntExist','cs',"Kalendář neexistuje!");
LngAdd('EventDoesntExist','en',"Event doesn't exist!");
LngAdd('EventDoesntExist','cs',"Událost neexistuje!");
LngAdd('PageCantHaveSubPages','en',"Cannot delete pages with sub-pages!");
LngAdd('PageCantHaveSubPages','cs',"Nelze vymazat stránku, která obsahuje pod-stránky!");
LngAdd('CategoryMustBeEmpty','en',"Category must be empty!");
LngAdd('CategoryMustBeEmpty','cs',"Kategorie musí být prázdná!");
LngAdd('AlbumMustBeEmpty','en',"Album must be empty!");
LngAdd('AlbumMustBeEmpty','cs',"Album musí být prázdné!");
LngAdd('PageDeleted','en',"Page deleted.");
LngAdd('PageDeleted','cs',"Stránka vymazána.");
LngAdd('PageDeletingError','en',"An error ocurred during page deletion.");
LngAdd('PageDeletingError','cs',"Při vymazávání stránky došlo k chybě.");
LngAdd('NewUser','en',"New user");
LngAdd('NewUser','cs',"Nový uživatel");
LngAdd('EditUser','en',"Edit user");
LngAdd('EditUser','cs',"Upravit uživatele");
LngAdd('NewUsersRight','en',"New user's right");
LngAdd('NewUsersRight','cs',"Nové uživatelské právo");
LngAdd('EditUsersRight','en',"Edit user's right");
LngAdd('EditUsersRight','cs',"Upravit uživatelské právo");
LngAdd('Function','en',"Function");
LngAdd('Function','cs',"Funkce");
LngAdd('Location','en',"Location");
LngAdd('Location','cs',"Umístění");
LngAdd('Level','en',"Level");
LngAdd('Level','cs',"Patro");
LngAdd('Doors','en',"Doors");
LngAdd('Doors','cs',"Dveře");
LngAdd('-Building-','en',"- Building -");
LngAdd('-Building-','cs',"- Budova -");
LngAdd('Buildings','en',"Buildings");
LngAdd('Buildings','cs',"Budovy");
LngAdd('FunctionDescription','en',"Function description");
LngAdd('FunctionDescription','cs',"Popis funkce");
LngAdd('PoliticalParties','en',"Political parties");
LngAdd('PoliticalParties','cs',"Politické strany");
LngAdd('NoPoliticalParty','en',"No political party");
LngAdd('NoPoliticalParty','cs',"Žádná politická strana");
LngAdd('PoliticalParty','en',"Political party");
LngAdd('PoliticalParty','cs',"Politická strana");
LngAdd('NewPoliticalParty','en',"New political party");
LngAdd('NewPoliticalParty','cs',"Nová politická strana");
LngAdd('EditPoliticalParty','en',"Edit political party");
LngAdd('EditPoliticalParty','cs',"Upravit politickou stranu");
LngAdd('FirstName','en',"First name");
LngAdd('FirstName','cs',"Křestní jméno");
LngAdd('LastName','en',"Last name");
LngAdd('LastName','cs',"Příjmení");
LngAdd('FullName','en',"Full name");
LngAdd('FullName','cs',"Celé jméno");
LngAdd('DisplayNameAs','en',"Display name as");
LngAdd('DisplayNameAs','cs',"Zobrazit jméno jako");
LngAdd('Layouts','en',"Layouts");
LngAdd('Layouts','cs',"Layouty");
LngAdd('Plugins','en',"Plugins");
LngAdd('Plugins','cs',"Moduly");
LngAdd('Statistics','en',"Statistics");
LngAdd('Statistics','cs',"Statistiky");
LngAdd('Agendas','en',"Agendas");
LngAdd('Agendas','cs',"Agendy");
LngAdd('NewAgenda','en',"New agenda");
LngAdd('NewAgenda','cs',"Nová agenda");
LngAdd('EditAgenda','en',"Edit agenda");
LngAdd('EditAgenda','cs',"Upravit agendu");
LngAdd('FirstAndLastName','en',"First and Last name");
LngAdd('FirstAndLastName','cs',"Jméno a příjmení");
LngAdd('Telephone','en',"Telephone");
LngAdd('Telephone','cs',"Telefon");
LngAdd('TelephonePlaceHolder','en',"420315123456");
LngAdd('TelephonePlaceHolder','cs',"420315123456");
LngAdd('MobilePhone','en',"Cell phone");
LngAdd('MobilePhone','cs',"Mobilní telefon");
LngAdd('MobilePhoneShort','en',"Cell");
LngAdd('MobilePhoneShort','cs',"Mobil");
LngAdd('MobilePhonePlaceHolder','en',"420777123456");
LngAdd('MobilePhonePlaceHolder','cs',"420777123456");
LngAdd('UserIsChiefOfDepartment','en',"User is chief of department %1.");
if(ModuleEnabled('cityhall')) { $str = "Uživatel je vedoucím odboru %1."; } else { $str = "Uživatel je vedoucím oddělení %1."; }
LngAdd('UserIsChiefOfDepartment','cs',$str);
LngAdd('Departments','en',"Departments");
if(ModuleEnabled('cityhall')) { $str = "Odbory"; } else { $str = "Oddělení"; }
LngAdd('Departments','cs',$str);
LngAdd('AllDepartments','en',"All departments");
if(ModuleEnabled('cityhall')) { $str = "Všechny odbory"; } else { $str = "Všechna oddělení"; }
LngAdd('AllDepartments','cs',$str);
LngAdd('IsChiefOfDepartment','en',"Is chief of department");
if(ModuleEnabled('cityhall')) { $str = "Je vedoucí odboru"; } else { $str = "Je vedoucí oddělení"; }
LngAdd('IsChiefOfDepartment','cs',$str);
LngAdd('Department','en',"Department");
if(ModuleEnabled('cityhall')) { $str = "Odbor"; } else { $str = "Oddělení"; }
LngAdd('Department','cs',$str);
LngAdd('NewDepartment','en',"New department");
if(ModuleEnabled('cityhall')) { $str = "Nový odbor"; } else { $str = "Nové oddělení"; }
LngAdd('NewDepartment','cs',$str);
LngAdd('RenameDepartment','en',"Rename department");
if(ModuleEnabled('cityhall')) { $str = "Přejmenovat odbor"; } else { $str = "Přejmenovat oddělení"; }
LngAdd('RenameDepartment','cs',$str);
LngAdd('DeleteDepartment','en',"Delete department");
if(ModuleEnabled('cityhall')) { $str = "Smazat odbor"; } else { $str = "Smazat oddělení"; }
LngAdd('DeleteDepartment','cs',$str);
LngAdd('DepartmentMustBeEmpty','en',"Department must be empty!");
if(ModuleEnabled('cityhall')) { $str = "Odbor musí být prázdný!"; } else { $str = "Oddělení musí být prázdné!"; }
LngAdd('DepartmentMustBeEmpty','cs',$str);
LngAdd('ToRemoveDepartment','en',"to remove department \"%1\"");
if(ModuleEnabled('cityhall')) { $str = "smazat odbor \"%1\""; } else { $str = "smazat oddělení \"%1\""; }
LngAdd('ToRemoveDepartment','cs',$str);
LngAdd('EditDepartment','en',"Edit department");
if(ModuleEnabled('cityhall')) { $str = "Upravit odbor"; } else { $str = "Upravit oddělení"; }
LngAdd('EditDepartment','cs',$str);
LngAdd('SuperiorDepartment','en',"Superior department");
if(ModuleEnabled('cityhall')) { $str = "Nadřízený odbor"; } else { $str = "Nadřízené oddělení"; }
LngAdd('SuperiorDepartment','cs',$str);
LngAdd('DepartmentNo','en',"Department No.");
if(ModuleEnabled('cityhall')) { $str = "Číslo odboru"; } else { $str = "Číslo oddělení"; }
LngAdd('DepartmentNo','cs',$str);
LngAdd('DepartmentChief','en',"Department chief");
if(ModuleEnabled('cityhall')) { $str = "Vedoucí odboru"; } else { $str = "Vedoucí oddělení"; }
LngAdd('DepartmentChief','cs',$str);
LngAdd('BasicInformations','en',"Basic informations");
LngAdd('BasicInformations','cs',"Základní informace");
LngAdd('FontColor','en',"Font color");
LngAdd('FontColor','cs',"Barva písma");
LngAdd('TextColor','en',"Text color");
LngAdd('TextColor','cs',"Barva textu");
LngAdd('BackgroundColor','en',"Background color");
LngAdd('BackgroundColor','cs',"Barva pozadí");
LngAdd('Add','en',"Add");
LngAdd('Add','cs',"Přidat");
LngAdd('AddSubPage','en',"Add sub-page");
LngAdd('AddSubPage','cs',"Přidat podstránku");
LngAdd('MoveUp','en',"Move up");
LngAdd('MoveUp','cs',"Posunout výše");
LngAdd('MoveDown','en',"Move down");
LngAdd('MoveDown','cs',"Posunout níže");
LngAdd('DeletePage','en',"Delete page");
LngAdd('DeletePage','cs',"Smazat stránku");
LngAdd('Publish','en',"Publish");
LngAdd('Publish','cs',"Publikovat");
LngAdd('PublishToOfficialBoard','cs',"Vyvěsit na úřední desku");
LngAdd('DateOfPublicationOnOfficialBoard','cs',"Datum vyvěšení");
LngAdd('DateOfExpirationOnOfficialBoard','cs',"Datum sejmutí");
LngAdd('Restore','en',"Restore");
LngAdd('Restore','cs',"Obnovit");
LngAdd('CancelChanges','en',"Cancel changes");
LngAdd('CancelChanges','cs',"Stornovat úpravy");
LngAdd('Description','en',"Description");
LngAdd('Description','cs',"Popis");
LngAdd('Edit','en',"Edit");
LngAdd('Edit','cs',"Upravit");
LngAdd('New','en',"New");
LngAdd('New','cs',"Nový");
LngAdd('AcademicTitles','en',"Academic titles");
LngAdd('AcademicTitles','cs',"Akademické tituly");
LngAdd('AcademicTitle','en',"Academic title");
LngAdd('AcademicTitle','cs',"Akademický titul");
LngAdd('NewAcademicTitle','en',"New academic title");
LngAdd('NewAcademicTitle','cs',"Nový akademický titul");
LngAdd('EditAcademicTitle','en',"Edit academic title");
LngAdd('EditAcademicTitle','cs',"Upravit akademický titul");
LngAdd('UsersRights','en',"User's rights");
LngAdd('UsersRights','cs',"Uživatelská práva");
LngAdd('BuyLicense','en',"Buy license");
LngAdd('BuyLicense','cs',"Koupit licenci");
LngAdd('BuySubscription','en',"Buy subscription");
LngAdd('BuySubscription','cs',"Koupit předplatné");
LngAdd('OrderSubscription','en',"Order subscription");
LngAdd('OrderSubscription','cs',"Objednat na 1 rok");
LngAdd('SendSubscriptionOrder','en',"Send subscription order");
LngAdd('SendSubscriptionOrder','cs',"Odeslat objednávku předplatného");
LngAdd('SendOrder','en',"Send order");
LngAdd('SendOrder','cs',"Odeslat objednávku");
LngAdd('SubscriptionExpired','en',"Subscription expired");
LngAdd('SubscriptionExpired','cs',"Předplatné vypršelo");
LngAdd('LicenseExpired','en',"License expired");
LngAdd('LicenseExpired','cs',"Licence vypršela");
LngAdd('MyLicense','en',"My license");
LngAdd('MyLicense','cs',"Moje licence");
LngAdd('GetImprovements','en',"Get improvements");
LngAdd('GetImprovements','cs',"Získat vylepšení");
LngAdd('ItsTimeToBuyLicense','en',"It's time to buy license");
LngAdd('ItsTimeToBuyLicense','cs',"Je čas koupit licenci");
LngAdd('EditLicense','en',"Edit license");
LngAdd('EditLicense','cs',"Upravit licenci");
LngAdd('License','en',"License");
LngAdd('License','cs',"Licence");
LngAdd('Activated','en',"Activated");
LngAdd('Activated','cs',"Aktivováno");
LngAdd('Price','en',"Price");
LngAdd('Price','cs',"Cena");
LngAdd('LicenseOrders','en',"License orders");
LngAdd('LicenseOrders','cs',"Objednávky licencí");
LngAdd('PageIsBeingPrepared','en',"This page is being prepared.<br />Please come here later.");
LngAdd('PageIsBeingPrepared','cs',"Tato stránka se připravuje.<br />Přijďte prosím později.");
LngAdd('Task','en',"Task");
LngAdd('Task','cs',"Úkol");
LngAdd('Project','en',"Project");
LngAdd('Project','cs',"Projekt");
LngAdd('Appointment','en',"Appointment");
LngAdd('Appointment','cs',"Událost");
LngAdd('Event','en',"Event");
LngAdd('Event','cs',"Akce");
LngAdd('Meeting','en',"Meeting");
LngAdd('Meeting','cs',"Schůzka");
LngAdd('Anniversary','en',"Anniversary");
LngAdd('Anniversary','cs',"Výročí");
LngAdd('Note','en',"Note");
LngAdd('Note','cs',"Poznámka");
LngAdd('Daynote','en',"Day-note");
LngAdd('Daynote','cs',"Poznámka ke dni");
LngAdd('Contact','en',"Contact");
LngAdd('Contact','cs',"Kontakt");
LngAdd('Message','en',"Message");
LngAdd('Message','cs',"Zpráva");
LngAdd('Type','en',"Type");
LngAdd('Type','cs',"Typ");
LngAdd('Shortcut','en',"Shortcut");
LngAdd('Shortcut','cs',"Zkratka");
LngAdd('FullTitle','en',"Full title");
LngAdd('FullTitle','cs',"Celý název");
LngAdd('ShowInList','en',"Show in list");
LngAdd('ShowInList','cs',"Zobrazit v seznamu");
LngAdd('ShowInContacts','en',"Show in contacts");
LngAdd('ShowInContacts','cs',"Zobrazit v kontaktech");
LngAdd('ShowUserInContacts','en',"Show user in contacts");
LngAdd('ShowUserInContacts','cs',"Zobrazit uživatele v kontaktech");
LngAdd('ShowDepartmentInContacts','en',"Show department in contacts");
if(ModuleEnabled('cityhall')) { $str = "odbor"; } else { $str = "oddělení"; }
LngAdd('ShowDepartmentInContacts','cs',"Zobrazit $str v kontaktech");
LngAdd('NoSuperiorDepartment','en',"No superior department");
if(ModuleEnabled('cityhall')) { $str = "Žádný nadřízený odbor"; } else { $str = "Žádné nadřízené oddělení"; }
LngAdd('NoSuperiorDepartment','cs',$str);
LngAdd('-SELECT-','en',"--- SELECT ---");
LngAdd('-SELECT-','cs',"--- VYBERTE ---");
LngAdd('LoadingPleaseWait','en',"Loading. Please wait.");
LngAdd('LoadingPleaseWait','cs',"Nahrávání. Prosím čekejte.");
LngAdd('Loading...','en',"Loading...");
LngAdd('Loading...','cs',"Načítání...");
LngAdd('SomeItemsAreNotDefined','en',"Some items are not defined!");
LngAdd('SomeItemsAreNotDefined','cs',"Některé položky nejsou definovány!");
LngAdd('ItemIsNotDefined','en',"Item \"%1\" is not defined!");
LngAdd('ItemIsNotDefined','cs',"Položka \"%1\" není definována!");
LngAdd('OrganizerWithIDNotFound','en',"Organizer with ID \"%1\" not found!");
LngAdd('OrganizerWithIDNotFound','cs',"Organizér s ID \"%1\" nenalezen!");
LngAdd('ToRemoveUserFromYourContacts','en',"to remove user \"%1\" from your contacts");
LngAdd('ToRemoveUserFromYourContacts','cs',"odebrat uživatele \"%1\" z Vašich kontaktů");
LngAdd('ItemNotFound','en',"Item not found!");
LngAdd('ItemNotFound','cs',"Položka nenalezena!");
LngAdd('NoItemsFound','en',"No items found");
LngAdd('NoItemsFound','cs',"Žádné položky nenalezeny");
LngAdd('SelectOneOrMoreCalendars','en',"Select one or more calendars");
LngAdd('SelectOneOrMoreCalendars','cs',"Vyberte jeden či více kalendářů");
LngAdd('SelectOneOrMoreTags','en',"Select one or more tags");
LngAdd('SelectOneOrMoreTags','cs',"Vyberte jeden či více štítků");
LngAdd('SelectAll','en',"Select all");
LngAdd('SelectAll','cs',"Vybrat vše");
LngAdd('UnknownOrganizerType','en',"Unknown organizer type \"%1\"!");
LngAdd('UnknownOrganizerType','cs',"Neznámý typ organizéru \"%1\"!");
LngAdd('CreateNewOrganizer','en',"Create new organizer");
LngAdd('CreateNewOrganizer','cs',"Vytvořit nový organizér");
LngAdd('CreateOrganizer','en',"Create organizer");
LngAdd('CreateOrganizer','cs',"Vytvořit organizér");
LngAdd('CreateCalendar','en',"Create calendar");
LngAdd('CreateCalendar','cs',"Vytvořit kalendář");
LngAdd('NewOrganizer','en',"New organizer");
LngAdd('NewOrganizer','cs',"Nový organizér");
LngAdd('EditOrganizer','en',"Edit organizer");
LngAdd('EditOrganizer','cs',"Upravit organizér");
LngAdd('FullOrganizer','en',"Full organizer");
LngAdd('FullOrganizer','cs',"Plnohodnotný organizér");
LngAdd('CalendarOfPublicEvents','en',"Calendar of public events");
LngAdd('CalendarOfPublicEvents','cs',"Kalendář společenských událostí");
LngAdd('ConferenceRoomBookingCalendar','en',"Conference room booking calendar");
LngAdd('ConferenceRoomBookingCalendar','cs',"Kalendář rezervace zasedací místnosti");
LngAdd('CarBookingCalendar','en',"Car booking calendar");
LngAdd('CarBookingCalendar','cs',"Kalendář rezervace vozu");
LngAdd('OrganizerType','en',"Organizer type");
LngAdd('OrganizerType','cs',"Typ organizéru");
LngAdd('NewPublicEvent','en',"New event");
LngAdd('NewPublicEvent','cs',"Nová událost");
LngAdd('EditPublicEvent','en',"Edit event");
LngAdd('EditPublicEvent','cs',"Upravit akci");
LngAdd('OnlyICanSeeThisOrganizer','en',"Only I can see this organizer");
LngAdd('OnlyICanSeeThisOrganizer','cs',"Pouze já mohu vidět tento organizér");
LngAdd('VisibleForAllVisitors','en',"Visible for all visitors");
LngAdd('VisibleForAllVisitors','cs',"Viditelný pro všechny návštěvníky");
LngAdd('VisibleForAllLoggedInUsers','en',"Visible for all logged-in users");
LngAdd('VisibleForAllLoggedInUsers','cs',"Viditelný pro všechny přihlášené uživatele");
LngAdd('VisibleForAllMyContacts','en',"Visible for all my contacts");
LngAdd('VisibleForAllMyContacts','cs',"Viditelný pro všechny mé kontakty");
LngAdd('OnlyICanEditThisOrganizer','en',"Only I can edit this organizer");
LngAdd('OnlyICanEditThisOrganizer','cs',"Pouze já mohu editovat tento organizér");
LngAdd('EditableByAllVisitors','en',"Editable by all visitors");
LngAdd('EditableByAllVisitors','cs',"Editovatelný všemi návštěvníky");
LngAdd('EditableByAllLoggedInUsers','en',"Editable by all logged-in users");
LngAdd('EditableByAllLoggedInUsers','cs',"Editovatelný všemi přihlášenými uživateli");
LngAdd('EditableByAllMyContacts','en',"Editable by all my contacts");
LngAdd('EditableByAllMyContacts','cs',"Editovatelný všemi mými kontakty");
LngAdd('ErrorGettingOrganizerID','en',"Error while getting Organizer ID.");
LngAdd('ErrorGettingOrganizerID','cs',"Chyba při získávání ID Organizéru.");
LngAdd('ErrorInsertingNewItem','en',"Error while inserting new item.");
LngAdd('ErrorInsertingNewItem','cs',"Chyba při vkládání nové položky.");
LngAdd('UserIDMustBeNumber','en',"UserID must be a number!");
LngAdd('UserIDMustBeNumber','cs',"ID uživatele musí být číslo!");
LngAdd('PageIDMustBeNumber','en',"PageID must be a number!");
LngAdd('PageIDMustBeNumber','cs',"ID stránky musí být číslo!");
LngAdd('IDMustBeNumber','en',"ID must be a number!");
LngAdd('IDMustBeNumber','cs',"ID musí být číslo!");
LngAdd('Back','en',"Back");
LngAdd('Back','cs',"Zpět");
LngAdd('Cancel','en',"Cancel");
LngAdd('Cancel','cs',"Storno");
LngAdd('Close','en',"Close");
LngAdd('Close','cs',"Zavřít");
LngAdd('Save','en',"Save");
LngAdd('Save','cs',"Uložit");
LngAdd('SaveText','en',"Save text");
LngAdd('SaveText','cs',"Uložit text");
LngAdd('Undo','en',"Undo");
LngAdd('Undo','cs',"Zpět");
LngAdd('Redo','en',"Redo");
LngAdd('Redo','cs',"Opakovat");
LngAdd('SaveChanges','en',"Save changes");
LngAdd('SaveChanges','cs',"Uložit změny");
LngAdd('SaveChangesInSharedRecord','en',"Save changes in shared record");
LngAdd('SaveChangesInSharedRecord','cs',"Uložit změny ve sdíleném záznamu");
LngAdd('EditSourceCode','en',"Edit source code");
LngAdd('EditSourceCode','cs',"Upravit zdrojový kód");
LngAdd('Delete','en',"Delete");
LngAdd('Delete','cs',"Vymazat");
LngAdd('OK','en',"OK");
LngAdd('OK','cs',"OK");
LngAdd('Caption','en',"Caption");
LngAdd('Caption','cs',"Popis");
LngAdd('Title','en',"Title");
LngAdd('Title','cs',"Název");
LngAdd('InformativeTitle','en',"Informative title");
LngAdd('InformativeTitle','cs',"Informační popisek");
LngAdd('TitleInLanguage','en',"Title in language %1");
LngAdd('TitleInLanguage','cs',"Název v jazyce %1");
LngAdd('DialogWindow','en',"Dialog window");
LngAdd('DialogWindow','cs',"Dialogové okno");
LngAdd('ItemMustBeFilled','cs',"Položka \"%1\" musí být vyplněna!");
LngAdd('SelectAtLeastOneItemInList','cs',"Vyberte nejméně jednu položku v seznamu \"%1\"!");
LngAdd('ItemMustBeNumber','cs',"Položka \"%1\" musí být číslo!");
LngAdd('RecordWithIDIsNotAvailableOrDoesNotExist','cs',"Záznam s ID = \"%1\" není dostupný nebo neexistuje!");
LngAdd('ItemContainsInvalidValues','cs',"Položka \"%1\" obsahuje neplatné hodnoty!");
LngAdd('ItemWithIDRemoved','cs',"Položka s ID = %1 odstraněna.");
LngAdd('MissingCaption','en',"Item's caption missing");
LngAdd('MissingCaption','cs',"Chybí popis položky");
LngAdd('MissingTitle','en',"Item's title missing.");
LngAdd('MissingTitle','cs',"Chybí název položky.");
LngAdd('InviteFriends','en',"Invite friends");
LngAdd('InviteFriends','cs',"Pozvat přátele");
LngAdd('SwitchToUnsecuredConnection','en',"Switch to unsecured connection");
LngAdd('SwitchToUnsecuredConnection','cs',"Přepnout na nezabezpečené spojení");
LngAdd('SwitchToSecuredSSLConnection','en',"Switch to secured SSL connection");
LngAdd('SwitchToSecuredSSLConnection','cs',"Přepnout na zabezpečené spojení SSL");
LngAdd('NewAccount','en',"New account");
LngAdd('NewAccount','cs',"Nový účet");
LngAdd('NewRegistration','en',"New registration");
LngAdd('NewRegistration','cs',"Nová registrace");
LngAdd('Registration','en',"Registration");
LngAdd('Registration','cs',"Registrace");
LngAdd('DoCreateNewAccount','en',"Create new account");
LngAdd('DoCreateNewAccount','cs',"Vytvořit nový účet");
LngAdd('DoRegister','en',"Register");
LngAdd('DoRegister','cs',"Zaregistrovat");
LngAdd('OldPassword','en',"Old password");
LngAdd('OldPassword','cs',"Původní heslo");
LngAdd('ChangePassword','en',"Change password");
LngAdd('ChangePassword','cs',"Změnit heslo");
LngAdd('NewPassword','en',"New password");
LngAdd('NewPassword','cs',"Nové heslo");
LngAdd('NewPasswordAgain','en',"New password (again)");
LngAdd('NewPasswordAgain','cs',"Nové heslo (znovu)");
LngAdd('CreatePassword','en',"Create password");
LngAdd('CreatePassword','cs',"Vytvořte heslo");
LngAdd('TheSamePasswordAgain','en',"The same password (again)");
LngAdd('TheSamePasswordAgain','cs',"Stejné heslo (znovu)");
LngAdd('TermsAgreement','en',"I aggree with <a href=\"".$urlTERMS."\" target=\"_blank\">terms of use</a>");
LngAdd('TermsAgreement','cs',"Souhlasím s <a href=\"".$urlTERMS."\" target=\"_blank\">podmínkami používání</a>");
LngAdd('TermsAgreement2','en',"I aggree with <a href=\"".$urlTERMS."\" target=\"_blank\" onclick=\"PIM_Terms();return false;\">terms of use</a>");
LngAdd('TermsAgreement2','cs',"Souhlasím s <a href=\"".$urlTERMS."\" target=\"_blank\" onclick=\"PIM_Terms();return false;\">podmínkami používání</a>");
LngAdd('TestNewPasswordTooShort','en',"New password is too short!<br />Minimal length of password is 6 characters.");
LngAdd('TestNewPasswordTooShort','cs',"Nové heslo je příliš krátké!<br />Minimální délka hesla je 6 znaků.");
LngAdd('TestNewPasswordTooLong','en',"New password is too long!<br />Maximal length of password is 128 characters.");
LngAdd('TestNewPasswordTooLong','cs',"Nové heslo je příliš dlouhé!<br />Maximální délka hesla je 128 znaků.");
LngAdd('TestNewPasswordSpace','cs',"Nové heslo nesmí obsahovat mezeru!<br />Povoleny jsou pouze znaky abecedy bez diakritiky (háčků a čárek), čísla, tečka, podtržítko a pomlčka.");
LngAdd('TestNewPasswordBadChars','cs',"Nové heslo obsahuje nepovolené znaky!<br />Povoleny jsou pouze znaky abecedy bez diakritiky (háčků a čárek), čísla, tečka, mezera, podtržítko a pomlčka.");
LngAdd('NewPasswordsAreNotSame','cs',"Nové heslo a Nové heslo (znovu) nejsou stejná!");
LngAdd('MustCheckTermsOfUse','cs',"Pro vytvoření musíte souhlasit s Podmínkami používání!");
LngAdd('TermsOfUse','en',"Terms of use");
LngAdd('TermsOfUse','cs',"Podmínky používání");
LngAdd('FormFieldCantBeEmpty','cs',"Formulářové pole \"%1\" nesmí být prázdné!");
LngAdd('FormFieldIsTooLong','cs',"Text ve formulářovém poli \"%1\" je příliš dlouhý!");
LngAdd('FormFieldMustBeNumber','cs',"Formulářové pole \"%1\" musí být číslo!");
LngAdd('SelectValueInFormField','cs',"Vyberte hodnotu ve formulářovém poli \"%1\"!");
LngAdd('UserAccountDeactivated','en',"User account \"%1\" was deactivated.");
LngAdd('UserAccountDeactivated','cs',"Uživatelský účet \"%1\" byl deaktivován.");
LngAdd('UserAccountRestored','en',"User account \"%1\" was restored.");
LngAdd('UserAccountRestored','cs',"Uživatelský účet \"%1\" byl obnoven.");
LngAdd('UserAccountDeleted','en',"User account \"%1\" was deleted.");
LngAdd('UserAccountDeleted','cs',"Uživatelský účet \"%1\" byl vymazán.");
LngAdd('UserAccountNotFound','en',"User account not found.");
LngAdd('UserAccountNotFound','cs',"Uživatelský účet nebyl nalezen.");
LngAdd('ItemSuccessfullyAdded','en',"Item was successfully added.");
LngAdd('ItemSuccessfullyAdded','cs',"Položka byla úspěšně přidána.");
LngAdd('ItemSuccessfullyUpdated','en',"Item was successfully updated.");
LngAdd('ItemSuccessfullyUpdated','cs',"Položka byla úspěšně aktualizována.");
LngAdd('Yes','en',"Yes");
LngAdd('Yes','cs',"Ano");
LngAdd('No','en',"No");
LngAdd('No','cs',"Ne");
LngAdd('DeleteItem','en',"Delete item");
LngAdd('DeleteItem','cs',"Vymazat položku");
LngAdd('Remove','en',"Remove");
LngAdd('Remove','cs',"Odstranit");
LngAdd('Rename','en',"Rename");
LngAdd('Rename','cs',"Přejmenovat");
LngAdd('RemoveItem','en',"Remove item");
LngAdd('RemoveItem','cs',"Odstranit položku");
LngAdd('DeleteDocument','en',"Delete document");
LngAdd('DeleteDocument','cs',"Odstranit dokument");
LngAdd('ResetItem','en',"Reset item");
LngAdd('ResetItem','cs',"Resetovat položku");
LngAdd('ResetDocument','en',"Reset document");
LngAdd('ResetDocument','cs',"Resetovat dokument");
LngAdd('DoYouReallyWant','en',"Do you really want");
LngAdd('DoYouReallyWant','cs',"Opravdu si přejete");
LngAdd('ToRestoreUserAccount','en',"to retsore user account \"%1\"");
LngAdd('ToRestoreUserAccount','cs',"obnovit uživatelský účet \"%1\"");
LngAdd('ToRemoveItem','en',"to remove item \"%1\"");
LngAdd('ToRemoveItem','cs',"odstranit položku \"%1\"");
LngAdd('ToRemoveDocument','en',"to remove document \"%1\"");
LngAdd('ToRemoveDocument','cs',"odstranit dokument \"%1\"");
LngAdd('ToResetItem','en',"to reset item \"%1\"");
LngAdd('ToResetItem','cs',"resetovat položku \"%1\"");
LngAdd('ToResetDocument','en',"to reset document \"%1\"");
LngAdd('ToResetDocument','cs',"resetovat dokument \"%1\"");
LngAdd('ToDeleteTag','en',"to delete tag \"%1\"");
LngAdd('ToDeleteTag','cs',"smazat štítek \"%1\"");
LngAdd('ToDeleteRecord','en',"to delete record (%1) \"%2\"");
LngAdd('ToDeleteRecord','cs',"smazat záznam (%1) \"%2\"");
LngAdd('ToDeleteContactsGroup','en',"to delete contacts group \"%1\"");
LngAdd('ToDeleteContactsGroup','cs',"smazat skupinu kontaktů \"%1\"");
LngAdd('DeleteContactsGroup','en',"Delete contacts group");
LngAdd('DeleteContactsGroup','cs',"Smazat skupinu kontaktů");
LngAdd('ToOpenLinkWithoutSavingChangesInOpenedRecord','en',"to open link without saving changes in opened record");
LngAdd('ToOpenLinkWithoutSavingChangesInOpenedRecord','cs',"přejít na odkaz bez uložení změn v otevřeném záznamu");
LngAdd('ToCloneRecordWithoutSavingChangesInOpenedRecord','en',"to clone record without saving changes in opened record");
LngAdd('ToCloneRecordWithoutSavingChangesInOpenedRecord','cs',"klonovat záznam bez uložení změn v otevřeném záznamu");
LngAdd('ToDeleteVideo','en',"to delete video \"%1\"");
LngAdd('ToDeleteVideo','cs',"smazat video \"%1\"");
LngAdd('ToDeleteImage','en',"to delete image \"%1\"");
LngAdd('ToDeleteImage','cs',"smazat obrázek \"%1\"");
LngAdd('ToRemoveAlbum','en',"to remove album \"%1\"");
LngAdd('ToRemoveAlbum','cs',"odstranit album \"%1\"");
LngAdd('ToRemoveNews','en',"to remove news \"%1\"");
LngAdd('ToRemoveNews','cs',"odstranit aktualitu \"%1\"");
LngAdd('ToRemovePage','en',"to remove page \"%1\"");
LngAdd('ToRemovePage','cs',"odstranit stránku \"%1\"");
LngAdd('ToRemoveCategory','en',"to remove category \"%1\"");
LngAdd('ToRemoveCategory','cs',"odstranit kategorii \"%1\"");
LngAdd('ToDeactivateUserAccount','en',"to deactivate user account \"%1\"");
LngAdd('ToDeactivateUserAccount','cs',"deaktivovat uživatelský účet \"%1\"");
LngAdd('ToActivateLicenseOrder','en',"to activate license order \"%1\"");
LngAdd('ToActivateLicenseOrder','cs',"aktivovat objednávku licence \"%1\"");
LngAdd('ToRemoveUser','en',"to remove user \"%1\"");
LngAdd('ToRemoveUser','cs',"odstranit uživatele \"%1\"");
LngAdd('ToRemoveThisImage','en',"to remove this image");
LngAdd('ToRemoveThisImage','cs',"odstranit tento obrázek");
LngAdd('ToRemoveThisItem','en',"to remove this item");
LngAdd('ToRemoveThisItem','cs',"odstranit tuto položku");
LngAdd('ToLeaveWithoutSavingChanges','en',"to leave without saving changes");
LngAdd('ToLeaveWithoutSavingChanges','cs',"odejít bez uložení změn");
LngAdd('ChangeImage','en',"Change image");
LngAdd('ChangeImage','cs',"Změnit obrázek");
LngAdd('ToAServer','en',"to a server");
LngAdd('ToAServer','cs',"k serveru");
LngAdd('YouWereLoggedOut','en',"You were logged out from user account.");
LngAdd('YouWereLoggedOut','cs',"Byli jste odhlášeni od uživatelského účtu.");
LngAdd('YouCantEditThisRecord','en',"You can't edit this record");
LngAdd('YouCantEditThisRecord','cs',"Tento záznam nemůžete upravit");
LngAdd('YouCantDoThis','en',"You can't do this");
LngAdd('YouCantDoThis','cs',"Toto nemůžete udělat");
LngAdd('ThisItemCantBeChanged','en',"This item can't be changed.");
LngAdd('ThisItemCantBeChanged','cs',"Tato položka nemůže být změněna.");
LngAdd('YouCantBeLoggedIn','en',"You can't be logged in to display this page.");
LngAdd('YouCantBeLoggedIn','cs',"Pro zobrazení této stránky nesmíte být přihlášeni.");
LngAdd('YouMustBeLoggedIn','en',"You must be logged in");
LngAdd('YouMustBeLoggedIn','cs',"Musíte být přihlášeni");
LngAdd('UserIsNotLoggedIn','en',"User is not logged in!");
LngAdd('UserIsNotLoggedIn','cs',"Uživatel není přihlášen!<br />Pro tuto akci se musíte přihlásit k Vašemu uživatelskému účtu kliknutím na \"přihlášení\".<br />Pokud uživatelský účet ještě nemáte, můžete si jej zdarma vytvořit kliknutím na \"nová registrace\".");
LngAdd('AdminIsNotLoggedIn','en',"Admin is not logged in!");
LngAdd('AdminIsNotLoggedIn','cs',"Správce není přihlášen!");
LngAdd('LoginSuccessful','en',"You are now logged into \"%1\" user account.");
LngAdd('LoginSuccessful','cs',"Nyní jste přihlášeni k uživatelskému účtu \"%1\".");
LngAdd('LoginUsernameDoesntExist','en',"User account \"%1\" doesn't exist!");
LngAdd('LoginUsernameDoesntExist','cs',"Uživatelský účet \"%1\" neexistuje!");
LngAdd('UserAccountDoesntExist','en',"User account doesn't exist!");
LngAdd('UserAccountDoesntExist','cs',"Uživatelský účet neexistuje!");
LngAdd('PasswordChangedSuccessfully','en',"Password changed successfully.");
LngAdd('PasswordChangedSuccessfully','cs',"Heslo úspěšně změněno.");
LngAdd('LoginBadPassword','en',"Bad password!");
LngAdd('LoginBadPassword','cs',"Neplatné heslo!<br /><br /><b>Myslíte, že zadáváte správné heslo?</b><br />V takovém případě je možné, že došlo k překlepu už při vytváření hesla. Problém vyřešíte tak, že po zavření tohoto okna kliknete na \"Zapomenuté heslo\", kde nastavíte Vaše heslo znovu.<br />");
LngAdd('IncorrectPassword','en',"Incorrect password!");
LngAdd('IncorrectPassword','cs',"Neplatné heslo!");
LngAdd('LoginPasswordError','en',"<h7>Incorrectly typed password!</h7>%1");
LngAdd('LoginPasswordError','cs',"<h7>Chybně zadané heslo!</h7>%1");
LngAdd('LoginEmailError','en',"<h7>Incorrectly typed e-mail!</h7>%1");
LngAdd('LoginEmailError','cs',"<h7>Chybně zadaný e-mail!</h7>%1");
LngAdd('IncorrectlyTypedEmail','en',"Incorrectly typed e-mail!");
LngAdd('IncorrectlyTypedEmail','cs',"Chybně zadaný e-mail!");
LngAdd('LoginUsernameIsNotEmail','en',"<h7>Incorrectly typped user's e-mail!</h7>%1");
LngAdd('LoginUsernameIsNotEmail','cs',"<h7>Chybně zadaný uživatelský e-mail!</h7>%1");
LngAdd('LoginUsernameIsNotUsername','en',"<h7>Incorrectly typed username!</h7>%1");
LngAdd('LoginUsernameIsNotUsername','cs',"<h7>Chybně zadané uživatelské jméno!</h7>%1");
LngAdd('NewPasswordRequestSent','cs',"Na e-mailovou adresu \"%1\" byly zaslány instrukce pro vytvoření nového hesla.");
LngAdd('NewPasswordRequestHashNotFound','cs',"Tento požadavek pro vytvoření nového hesla neexistuje nebo již byl zpracován.<br />Klikněte znovu na Zapomenuté heslo a opakujte akci.");
LngAdd('TestLoginIfID','cs',"Pokud zadáváte ID:");
LngAdd('TestLoginIfUsername','cs',"Pokud zadáváte Uživatelské jméno:");
LngAdd('TestLoginIfEmail','cs',"Pokud zadáváte E-mail:");
LngAdd('TestEmailTooShort','cs',"E-mailová adresa \"%1\" je příliš krátká!<br />Minimální délka e-mailové adresy je 6 znaků.");
LngAdd('TestEmailTooLong','cs',"E-mailová adresa \"%1\" je příliš dlouhá!<br />Maximální délka e-mailové adresy je 128 znaků.");
LngAdd('TestEmailAtMissing','cs',"E-mailová adresa musí obsahovat znak zavináč (@).");
LngAdd('TestEmailTooMuchAts','cs',"E-mailová adresa obsahuje více než jeden znak zavináč (@).<br />Adresa musí obsahovat přesně jeden tento znak.");
LngAdd('TestEmailSpace','cs',"E-mailová adresa nesmí obsahovat žádný znak \"mezera\"!");
LngAdd('TestEmailDotAfterAtMissing','cs',"Za znakem zavináč (@) není žádná tečka!<br />Za zavináčem musí být název serveru, tečka a koncovka (např. tedy seznam.cz).");
LngAdd('TestUsernameTooShort','en',"Username \"%1\" is too short!<br />Minimal length of username is 3 characters.");
LngAdd('TestUsernameTooShort','cs',"Uživatelské jméno \"%1\" je příliš krátké!<br />Minimální délka uživatelského jména jsou 3 znaky.");
LngAdd('TestUsernameTooLong','en',"Username \"%1\" is too long!<br />Maximal length of username is 128 characters.");
LngAdd('TestUsernameTooLong','cs',"Uživatelské jméno \"%1\" je příliš dlouhé!<br />Maximální délka uživatelského jména je 128 znaků.");
LngAdd('TestUsernameSpace','cs',"Uživatelské jméno nesmí obsahovat mezeru!<br />Povoleny jsou pouze znaky abecedy bez diakritiky (háčků a čárek), čísla, tečka, podtržítko a pomlčka.");
LngAdd('TestUsernameTooMuchHyphens','cs',"Uživatelské jméno nesmí obsahovat dvě a více pomlček v řadě!<br />Povoleny jsou pouze znaky abecedy bez diakritiky (háčků a čárek), čísla, tečka, podtržítko a pomlčka.");
LngAdd('TestUsernameBadChars','cs',"Uživatelské jméno \"%1\" obsahuje nepovolené znaky!<br />Povoleny jsou pouze znaky abecedy bez diakritiky (háčků a čárek), čísla, tečka, podtržítko a pomlčka.");
LngAdd('TestPasswordTooShort','en',"Password is too short!<br />Minimal length of password is 6 characters.");
LngAdd('TestPasswordTooShort','cs',"Heslo je příliš krátké!<br />Minimální délka hesla je 6 znaků.");
LngAdd('TestPasswordTooLong','en',"Password is too long!<br />Maximal length of password is 128 characters.");
LngAdd('TestPasswordTooLong','cs',"Heslo je příliš dlouhé!<br />Maximální délka hesla je 128 znaků.");
LngAdd('TestPasswordSpace','cs',"Heslo nesmí obsahovat mezeru!<br />Povoleny jsou pouze znaky abecedy bez diakritiky (háčků a čárek), čísla, tečka, podtržítko a pomlčka.");
LngAdd('TestPasswordBadChars','cs',"Heslo obsahuje nepovolené znaky!<br />Povoleny jsou pouze znaky abecedy bez diakritiky (háčků a čárek), čísla, tečka, mezera, podtržítko a pomlčka.");
LngAdd('LoginUsernameAlreadyExists','cs',"Uživatelský účet s uživatelským jménem \"%1\" již existuje!");
LngAdd('LoginEmailAlreadyExists','cs',"Uživatelský účet s e-mailem \"%1\" již existuje!");
LngAdd('UserEmailAuthEmailTitle','cs',"Autorizace e-mailové adresy uživatelského účtu");
LngAdd('LanguageName','en',"English");
LngAdd('LanguageName','cs',"Čeština");
LngAdd('ChangeLanguage','en',"Change language");
LngAdd('ChangeLanguage','cs',"Změnit jazyk");
LngAdd('Language','en',"Language");
LngAdd('Language','cs',"Jazyk");
LngAdd('Username','en',"Username");
LngAdd('Username','cs',"Uživatelské jméno");
LngAdd('Password','en',"Password");
LngAdd('Password','cs',"Heslo");
LngAdd('Email','en',"E-mail");
LngAdd('Email','cs',"E-mail");
LngAdd('Country','en',"Country");
LngAdd('Country','cs',"Země");
LngAdd('EmailOfYourAccount','en',"E-mail address of your user account");
LngAdd('EmailOfYourAccount','cs',"E-mail Vašeho uživatelského účtu");
LngAdd('LicenseVariant','en',"License variant");
LngAdd('LicenseVariant','cs',"Varianta licence");
LngAdd('OrderLicense','en',"Order license");
LngAdd('OrderLicense','cs',"Objednat licenci");
LngAdd('YouMustSelectLicenseVariant','cs',"Musíte vybrat variantu licence!");
LngAdd('UsernameOrEmail','en',"Username or E-mail");
LngAdd('UsernameOrEmail','cs',"Uživatelské jméno nebo E-mail");
LngAdd('DoLogin','en',"Log in");
LngAdd('DoLogin','cs',"Přihlásit");
LngAdd('UserLogin','en',"User login");
LngAdd('UserLogin','cs',"Přihlášení uživatele");
LngAdd('UserLoginError','en',"User login error");
LngAdd('UserLoginError','cs',"Chyba přihlášení uživatele");
LngAdd('UserLoginStringError','en',"User login error");
LngAdd('UserLoginStringError','cs',"Chyba v zadání uživatelských údajů");
LngAdd('UserIdMustBeNumber','en',"User ID must be a number.");
LngAdd('UserIdMustBeNumber','cs',"Uživatelské ID musí být číslo.");
LngAdd('UserRegistration','en',"User registration");
LngAdd('UserRegistration','cs',"Registrace uživatele");
LngAdd('GetNewPassword','en',"Get new password");
LngAdd('GetNewPassword','cs',"Získat nové heslo");
LngAdd('SetNewPassword','en',"Set new password");
LngAdd('SetNewPassword','cs',"Nastavit nové heslo");
LngAdd('BackToLogin','en',"Back to login");
LngAdd('BackToLogin','cs',"Zpět k přihlášení");
LngAdd('BackToHomepage','en',"Back to homepage");
LngAdd('BackToHomepage','cs',"Zpět na hlavní stránku");
LngAdd('BackToNews','en',"Back to news");
LngAdd('BackToNews','cs',"Zpět na aktuality");
LngAdd('Login','en',"Login");
LngAdd('Login','cs',"Přihlášení");
LngAdd('AuthCode','en',"Authentization code");
LngAdd('AuthCode','cs',"Autentizační kód");
LngAdd('Forbidden','en',"Forbidden");
LngAdd('Forbidden','cs',"Zakázáno");
LngAdd('YouDontHavePermissionThisAction','en',"You don't have permission to this action!");
LngAdd('YouDontHavePermissionThisAction','cs',"K této akci nemáte oprávnění!");
LngAdd('IntranetAccessNotAllowedFromThisIP','en',"Access to the intranet is not allowed from this IP!");
LngAdd('IntranetAccessNotAllowedFromThisIP','cs',"Přístup do intranetu není z této IP adresy povolen!");
LngAdd('TitleHasWrongLength','en',"Title has wrong length!<br />Minimal length is %1 characters and maximum length is %2 characters.");
LngAdd('TitleHasWrongLength','cs',"Název má chybnou délku!<br />Minimální délka je %1 znaků a maximální délka je %2 znaků.");
LngAdd('PageAlreadyExistsInThisNode','en',"Page with address \"%1\" already exists in this node!");
LngAdd('PageAlreadyExistsInThisNode','cs',"Stránka s adresou \"%1\" v tomto uzlu již existuje!");
LngAdd('NewPassAuthCodeBadLength','cs',"Chybná délka Autentizačního kódu!<br />Autentizační kód musí mít přesně 16 znaků.");
LngAdd('NewPassRequestNotFound','cs',"Požadavek k vytvoření nového hesla nebyl na serveru nalezen!");
LngAdd('OnlyAdminCanCreateAccount','en',"Only administrator can create new user account on this web.");
LngAdd('OnlyAdminCanCreateAccount','cs',"Pouze administrátor může vytvořit nový uživatelský účet na tomto webu.");
if($MTPS->UsernameIsEmail) { $username_or_email = Lng('Email'); } else { $username_or_email = Lng('UsernameOrEmail'); }
LngAdd('ForgottenPassInfo','cs',"Vyplňte ".$username_or_email." Vašeho uživatelského účtu, ke&nbsp;kterému má být vygenerována žádost o&nbsp;vytvoření nového hesla.<br />Další postup pro obnovu hesla bude zaslán na e-mailovou adresu přiřazenou k&nbsp;účtu.");
LngAdd('UserLoginRememberEmail','en',"Remember e-mail");
LngAdd('UserLoginRememberEmail','cs',"Pamatovat přihlašovací e-mail");
LngAdd('UserLoginRememberLogin','en',"Log in automatically");
LngAdd('UserLoginRememberLogin','cs',"Přihlašovat automaticky");
LngAdd('UserLoginForgottenPassword','en',"Forgotten password");
LngAdd('UserLoginForgottenPassword','cs',"Zapomenuté heslo");
LngAdd('UserLoginNewPassword','en',"New password");
LngAdd('UserLoginNewPassword','cs',"Nové heslo");
LngAdd('UserLoginNewAccount','en',"New user account");
LngAdd('UserLoginNewAccount','cs',"Nový uživatelský účet");
LngAdd('UserLoginCookiesMustBeEnabled','cs',"Soubory cookies musí být povoleny.");
LngAdd('LoginAddress','en',"Login address");
LngAdd('LoginAddress','cs',"Adresa pro přihlášení");
LngAdd('Created','en',"Created");
LngAdd('Created','cs',"Vytvořeno");
LngAdd('Changed','en',"Changed");
LngAdd('Changed','cs',"Změněno");
LngAdd('History','en',"History");
LngAdd('History','cs',"Historie");
LngAdd('LastLogin','en',"Last login");
LngAdd('LastLogin','cs',"Poslední přihlášení");
LngAdd('AccountType','en',"Account type");
LngAdd('AccountType','cs',"Typ účtu");
LngAdd('AccountType0','en',"Reader");
LngAdd('AccountType0','cs',"Čtenář");
LngAdd('AccountType1','en',"Administrator");
LngAdd('AccountType1','cs',"Administrátor");
LngAdd('AccountType2','en',"Manager");
LngAdd('AccountType2','cs',"Manažer");
LngAdd('AccountType3','en',"Editor");
LngAdd('AccountType3','cs',"Editor");
LngAdd('Never','en',"Never");
LngAdd('Never','cs',"Nikdy");
LngAdd('Yesterday','en',"Yesterday");
LngAdd('Yesterday','cs',"Včera");
LngAdd('Today','en',"Today");
LngAdd('Today','cs',"Dnes");
LngAdd('TodayIs','en',"Today is");
LngAdd('TodayIs','cs',"Dnes je");
LngAdd('Tomorrow','en',"Tomorrow");
LngAdd('Tomorrow','cs',"Zítra");
LngAdd('LicenseExpiration','en',"License expiration");
LngAdd('LicenseExpiration','cs',"Expirace licence");
LngAdd('Subject','en',"Subject");
LngAdd('Subject','cs',"Předmět");
LngAdd('Send','en',"Send");
LngAdd('Send','cs',"Odeslat");
LngAdd('WriteToUs','en',"Write to us");
LngAdd('WriteToUs','cs',"Napište nám");
LngAdd('NotSupportedYet','en',"Not supported yet");
LngAdd('NotSupportedYet','cs',"Zatím nepodporováno");
LngAdd('ThisFunctionIsNotFinishedYet','en',"This function is not finished yet.");
LngAdd('ThisFunctionIsNotFinishedYet','cs',"Tato funkce zatím není dokončena.");
LngAdd('TryItLaterPlease','en',"Try it later, please.");
LngAdd('TryItLaterPlease','cs',"Zkuste to prosím později.");
LngAdd('UserAccountCreated','cs',"Uživatelský účet \"%1\" byl úspěšně vytvořen.<br />Na e-mailovou adresu \"%2\" byly zaslány podrobné informace.");
$link = AddParam($urlEMAILAUTH,'Email',"%2");
$link = AddParam($link,'Hash',"%3");
LngAdd('UserEmailAuthEmailText','cs',"Dobrý den,<br />pro Váš uživatelský účet \"%1\" na serveru <a href=\"$urlWEB\" target=\"_blank\">".$_SERVER['HTTP_HOST']."</a> je nutné autorizovat e-mailovou adresu \"%2\" kliknutím na níže uvedený odkaz.<br />Autorizace e-mailové adresy slouží k ověření její pravosti, oprávněnosti k přístupu a funkčnosti zasílání e-mailů ze serveru.<br /><br /><span style=\"font-size: 175%; color: rgb(200,0,0);\">Pro potvrzení platnosti této e-mailové adresy klikněte na:</span><br /><a href=\"$link\" target=\"_blank\">$link</a>");
LngAdd('UserEmailAuthRequestSent','cs',"Na e-mailovou adresu \"%1\" byl zaslán požadavek pro autorizaci.");
LngAdd('UserNewAccountEmailTitle','cs',"Váš nový uživatelský účet byl vytvořen");
LngAdd('UserNewAccountEmailTitle2','cs',"Nastavení a heslo Vašeho nového uživatelského účtu na %1");
$st1 = "width: 120px; margin: 0; padding: 0 0 2px 0; white-space: nowrap; font-weight: normal; text-align: right; color: rgb(50,50,50); ";
$st2 = "margin: 0; padding: 0 0 2px 10px; ";
$table = "<table style=\"width: 90%; padding: 0; margin: 0; border-collapse: collapse; border-spacing: 0; \">";
$table.= "<tr><th style=\"$st1\">".str_replace(" ","&nbsp;",Lng('Username')).":</th><td style=\"$st2\">%1</td></tr>";
$table.= "<tr><th style=\"font-size:125%;$st1\">".str_replace(" ","&nbsp;",Lng('Password')).":</th><td style=\"$st2\">%3</td></tr>";
$table.= "<tr><th style=\"$st1\">".str_replace(" ","&nbsp;",Lng('Email')).":</th><td style=\"$st2\">%2</td></tr>";
$table.= "<tr><th style=\"$st1\">".str_replace(" ","&nbsp;",Lng('AccountType')).":</th><td style=\"$st2\">%4</td></tr>";
$table.= "<tr><th style=\"$st1\">".str_replace(" ","&nbsp;",Lng('LoginAddress')).":</th><td style=\"$st2\"><a href=\"".AddParam($urlWEB,'UserLoginUsername',"%1")."\" target=\"_blank\">$urlWEB</a></td></tr>";
$table.= "</table>";
LngAdd('UserNewAccountEmailText','cs',"Dobrý den,<br />na webu <a href=\"$urlWEB\" target=\"_blank\">".$_SERVER['HTTP_HOST']."</a> Vám byl vytvořen nový uživatelský účet.<br />$table");
LngAdd('NewPasswordRequestTitle','cs',"Požadavek k vytvoření nového hesla uživatelského účtu");
$link = AddParam($urlNEWPASSWORD,'ID',"%2");
$link = AddParam($link,'Hash',"%3");
$link_delete = AddParam($link,'DelReq',"true");
LngAdd('NewPasswordRequestText','cs',"Dobrý den,<br />pro Váš uživatelský účet \"%1\" na serveru <a href=\"$urlWEB\" target=\"_blank\">".$_SERVER['HTTP_HOST']."</a> byl zadán požadavek pro vytvoření nového hesla.<br /><br /><b style=\"font-size: 175%; color: rgb(200,0,0);\">Pokud si přejete nastavit nové heslo, klikněte následující odkaz: </b><br />\n<a href=\"$link\">$link</a><br /><br /><br />Pokud požadavek není od Vás, nebo již není aktuální, smažte jej kliknutím na: <a href=\"$link_delete\">$link_delete</a><br />Požadavek byl odeslán z IP adresy: ".$MTPS->IP);
LngAdd('NewPassOpenYourEmail','cs',"Nyní otevřete Vaši <span style=\"white-space: nowrap;\">e-mailovou</span> schránku, kde naleznete další instrukce.<br /><br /><a href=\"".$urlWEB."\">Zpět na hlavní stránku</a>");
LngAdd('NewPassOpenYourEmail','en',"Now open your <span style=\"white-space: nowrap;\">e-mail</span> for further instructions.<br /><br /><a href=\"".$urlWEB."\">Back to homepage</a>");
LngAdd('EmailAuthSuccess','en',"E-mail address authorization finished successfully.");
LngAdd('EmailAuthSuccess','cs',"Autorizace e-mailové adresy byla úspěšná.");
LngAdd('EmailAuthError1','en',"<h7>E-mail address authorization error</h7>Missing parameter \"Email\" or \"Hash\"!");
LngAdd('EmailAuthError1','cs',"<h7>Chyba autorizace e-mailové adresy</h7>Chybí parametr \"Email\" nebo \"Hash\"!");
LngAdd('EmailAuthError2','en',"<h7>E-mail address authorization error</h7>%1");
LngAdd('EmailAuthError2','cs',"<h7>Chyba autorizace e-mailové adresy</h7>%1");
LngAdd('EmailAuthError3','en',"<h7>E-mail address authorization error</h7>Parameter \"Hash\" has incorrect length!");
LngAdd('EmailAuthError3','cs',"<h7>Chyba autorizace e-mailové adresy</h7>Parametr \"Hash\" nemá správnou délku!");
LngAdd('EmailAuthError4','cs',"<h7>Chyba autorizace e-mailové adresy</h7>Požadavek pro autorizaci nebyl nalezen!<br />Požadavek buď neexistuje nebo již byla e-mailová adresa autorizována.");
LngAdd('EmailAuthError5','cs',"<h7>Chyba autorizace e-mailové adresy</h7>Uživatelský účet, pro který je vystaven tento požadavek na autorizaci, nebyl nalezen.");
LngAdd('FullNameOrCompanyName','en',"Full name or company name");
LngAdd('FullNameOrCompanyName','cs',"Celé jméno nebo název firmy");
LngAdd('NameOrCompany','en',"Name or company");
LngAdd('NameOrCompany','cs',"Jméno nebo firma");
LngAdd('Address','en',"Address");
LngAdd('Address','cs',"Adresa");
LngAdd('City','en',"City");
LngAdd('City','cs',"Město");
LngAdd('CityEx','en',"City/Village");
LngAdd('CityEx','cs',"Město/Obec");
LngAdd('CompanyEx','en',"Company/Firm/Organisation");
LngAdd('CompanyEx','cs',"Společnost/Firma/Organizace");
LngAdd('ZIP','en',"ZIP code");
LngAdd('ZIP','cs',"PSČ");
LngAdd('IC','en',"IČ");
LngAdd('IC','cs',"IČ");
LngAdd('DIC','en',"DIČ");
LngAdd('DIC','cs',"DIČ");
LngAdd('PhoneNumber','en',"Phone number");
LngAdd('PhoneNumber','cs',"Telefonní číslo");
LngAdd('optional','en',"optional");
LngAdd('optional','cs',"nepovinné");
LngAdd('AdminTitle','en',"Administration");
LngAdd('AdminTitle','cs',"Administrace");
LngAdd('AddNew','en',"Add new");
LngAdd('AddNew','cs',"Přidat nový");
LngAdd('NewContact','en',"New contact");
LngAdd('NewContact','cs',"Nový kontakt");
LngAdd('New(contact)','en',"New");
LngAdd('New(contact)','cs',"Nový");
LngAdd('Edit(contact)','en',"Edit");
LngAdd('Edit(contact)','cs',"Upravit");
LngAdd('NewTask','en',"New task");
LngAdd('NewTask','cs',"Nový úkol");
LngAdd('AddNewTask','en',"Add new task");
LngAdd('AddNewTask','cs',"Přidat nový úkol");
LngAdd('AddSubtask','en',"Add subtask");
LngAdd('AddSubtask','cs',"Přidat podúkol");
LngAdd('NoTasks','en',"No tasks.");
LngAdd('NoTasks','cs',"Žádné úkoly.");
LngAdd('EditTask','en',"Edit task");
LngAdd('EditTask','cs',"Upravit úkol");
LngAdd('DayNote','en',"Day note");
LngAdd('DayNote','cs',"Poznámka ke dni");
LngAdd('DayNotes','en',"Day notes");
LngAdd('DayNotes','cs',"Poznámky ke dni");
LngAdd('AddNewDayNote','en',"Add new day note");
LngAdd('AddNewDayNote','cs',"Přidat novou poznámku ke dni");
LngAdd('NoDayNotes','en',"No day notes.");
LngAdd('NoDayNotes','cs',"Žádné upomínky.");
LngAdd('NewDayNote','en',"New day note");
LngAdd('NewDayNote','cs',"Nová poznámka ke dni");
LngAdd('EditDayNote','en',"Edit day note");
LngAdd('EditDayNote','cs',"Upravit poznámku ke dni");
LngAdd('NewDaynote','en',"New day note");
LngAdd('NewDaynote','cs',"Nová poznámka ke dni");
LngAdd('EditDaynote','en',"Edit day note");
LngAdd('EditDaynote','cs',"Upravit poznámku ke dni");
LngAdd('Reminder','en',"Reminder");
LngAdd('Reminder','cs',"Upomínka");
LngAdd('NewReminder','en',"New reminder");
LngAdd('NewReminder','cs',"Nová upomínka");
LngAdd('AddNewReminder','en',"Add new reminder");
LngAdd('AddNewReminder','cs',"Přidat novou upomínku");
LngAdd('NoReminders','en',"No reminders.");
LngAdd('NoReminders','cs',"Žádné upomínky.");
LngAdd('EditReminder','en',"Edit reminder");
LngAdd('EditReminder','cs',"Upravit upomínku");
LngAdd('NewMeeting','en',"New meeting");
LngAdd('NewMeeting','cs',"Nová schůzka");
LngAdd('AddNewMeeting','en',"Add new meeting");
LngAdd('AddNewMeeting','cs',"Přidat novou schůzku");
LngAdd('NoMeetings','en',"No meetings.");
LngAdd('NoMeetings','cs',"Žádné schůzky.");
LngAdd('EditMeeting','en',"Edit meeting");
LngAdd('EditMeeting','cs',"Upravit schůzku");
LngAdd('NewNote','en',"New note");
LngAdd('NewNote','cs',"Nová poznámka");
LngAdd('AddNewNote','en',"Add new note");
LngAdd('AddNewNote','cs',"Přidat novou poznámku");
LngAdd('Uploading...','en',"Uploading...");
LngAdd('Uploading...','cs',"Nahrávám...");
LngAdd('Saving...','en',"Saving...");
LngAdd('Saving...','cs',"Ukládání...");
LngAdd('EditNote','en',"Edit note");
LngAdd('EditNote','cs',"Upravit poznámku");
LngAdd('NewEvent','en',"New event");
LngAdd('NewEvent','cs',"Nová akce");
LngAdd('AddNewEvent','en',"Add new event");
LngAdd('AddNewEvent','cs',"Přidat novou akci");
LngAdd('NoEvents','en',"No events.");
LngAdd('NoEvents','cs',"Žádné akce.");
LngAdd('EditEvent','en',"Edit event");
LngAdd('EditEvent','cs',"Upravit událost");
LngAdd('Clone','en',"Clone");
LngAdd('Clone','cs',"Klonovat");
LngAdd('CloneEvent','en',"Clone event");
LngAdd('CloneEvent','cs',"Klonovat událost");
LngAdd('CloneRecord','en',"Clone record");
LngAdd('CloneRecord','cs',"Klonovat záznam");
LngAdd('NewAppointment','en',"New appointment");
LngAdd('NewAppointment','cs',"Nová událost");
LngAdd('AddNewAppointment','en',"Add new appointment");
LngAdd('AddNewAppointment','cs',"Přidat novou událost");
LngAdd('NoAppointments','en',"No appointments");
LngAdd('NoAppointments','cs',"Žádné události.");
LngAdd('EditAppointment','en',"Edit appointment");
LngAdd('EditAppointment','cs',"Upravit událost");
LngAdd('NewAnniversary','en',"New anniversary");
LngAdd('NewAnniversary','cs',"Nové výročí");
LngAdd('NewBirthday','en',"New birthday");
LngAdd('NewBirthday','cs',"Nové narozeniny");
LngAdd('EditBirthday','en',"Edit birthday");
LngAdd('EditBirthday','cs',"Upravit narozeniny");
LngAdd('AddNewAnniversary','en',"Add new anniversary");
LngAdd('AddNewAnniversary','cs',"Přidat nové výročí");
LngAdd('AddAnniversary','en',"Add anniversary");
LngAdd('AddAnniversary','cs',"Přidat výročí");
LngAdd('NoAnniversaries','en',"No anniversaries.");
LngAdd('NoAnniversaries','cs',"Žádná výročí.");
LngAdd('EditAnniversary','en',"Edit anniversary");
LngAdd('EditAnniversary','cs',"Upravit výročí");
LngAdd('Birthday','en',"Birthday");
LngAdd('Birthday','cs',"Narozeniny");
LngAdd('AddBirthday','en',"Add birthday");
LngAdd('AddBirthday','cs',"Přidat narozeniny");
LngAdd('NewRecord','en',"New record");
LngAdd('NewRecord','cs',"Nový záznam");
LngAdd('EditRecord','en',"Edit record");
LngAdd('EditRecord','cs',"Upravit záznam");
LngAdd('AddSomethingNew','en',"Add something new");
LngAdd('AddSomethingNew','cs',"Přidat něco nového");
LngAdd('AddNewRecord','en',"Add new");
LngAdd('AddNewRecord','cs',"Přidat nový záznam");
LngAdd('NewItem','en',"New item");
LngAdd('NewItem','cs',"Nová položka");
LngAdd('EditItem','en',"Edit item");
LngAdd('EditItem','cs',"Upravit položku");
LngAdd('NewMessage','en',"New message");
LngAdd('NewMessage','cs',"Nová zpráva");
LngAdd('EditMessage','en',"Edit message");
LngAdd('EditMessage','cs',"Upravit zprávu");
LngAdd('NewTaskList','en',"New task-list");
LngAdd('NewTaskList','cs',"Nový seznam úkolů");
LngAdd('EditTaskList','en',"Edit task-list");
LngAdd('EditTaskList','cs',"Upravit seznam úkolů");
LngAdd('ModuleNotSupportedYet','en',"Module is not supported yet.");
LngAdd('ModuleNotSupportedYet','cs',"Modul zatím není podporován.");
LngAdd('Subscribe','en',"Subscribe");
LngAdd('Subscribe','cs',"Přihlásit k odběru");
LngAdd('AddToContacts','en',"Add to contacts");
LngAdd('AddToContacts','cs',"Přidat do kontaktů");
LngAdd('RemoveFromContacts','en',"Remove from contacts");
LngAdd('RemoveFromContacts','cs',"Odebrat z kontaktů");
LngAdd('Remove(FromContacts)','en',"Remove");
LngAdd('Remove(FromContacts)','cs',"Odebrat");
LngAdd('SendMessage','en',"Send message");
LngAdd('SendMessage','cs',"Poslat zprávu");
LngAdd('ArrangeMeeting','en',"Arrange meeting");
LngAdd('ArrangeMeeting','cs',"Domluvit schůzku");
LngAdd('YouCantChangeThisSubscribersRole','en',"You can't change this subscribers role!");
LngAdd('YouCantChangeThisSubscribersRole','cs',"Nemůžete změnit roli tohoto odběratele!");
LngAdd('Unsubscribe','en',"Unsubscribe");
LngAdd('Unsubscribe','cs',"Odhlásit odběr");
LngAdd('Owner','en',"Owner");
LngAdd('Owner','cs',"Majitel");
LngAdd('Subscriber','en',"Subscriber");
LngAdd('Subscriber','cs',"Odběratel");
LngAdd('Contributor','en',"Contributor");
LngAdd('Contributor','cs',"Přispěvatel");
LngAdd('Manager','en',"Manager");
LngAdd('Manager','cs',"Manažer");
LngAdd('SubscribersRole','en',"Subscriber's role");
LngAdd('SubscribersRole','cs',"Odběratelova role");
LngAdd('YouCanSeeSubscribersFromYourOwnContactListOnly','en',"You can see subscribers from your own contact-list only.");
LngAdd('YouCanSeeSubscribersFromYourOwnContactListOnly','cs',"Můžete vidět pouze odběratele z Vašeho seznamu kontaktů.");
LngAdd('TotalSubscribers','en',"Total subscribers: %1");
LngAdd('TotalSubscribers','cs',"Celkem odběratelů: %1");
LngAdd('OfSubscribers','en',"Subscribers");
LngAdd('OfSubscribers','cs',"Odběratelů");
LngAdd('ListOfSubscribers','en',"List of subscribers");
LngAdd('ListOfSubscribers','cs',"Seznam odběratelů");
LngAdd('SearchForSubscriber','en',"Search for subscriber");
LngAdd('SearchForSubscriber','cs',"Najít odběratele");
LngAdd('ListOfTasks','en',"List of tasks");
LngAdd('ListOfTasks','cs',"Seznam úkolů");
LngAdd('ListOfContacts','en',"List of contacts");
LngAdd('ListOfContacts','cs',"Seznam kontaktů");
LngAdd('SearchForContacts','en',"Search for contacts");
LngAdd('SearchForContacts','cs',"Najít kontakty");
LngAdd('Length','en',"Length");
LngAdd('Length','cs',"Délka");
LngAdd('SaveToAs','en',"Save to %1 as %2");
LngAdd('SaveToAs','cs',"Uložit do %1 jako %2");
LngAdd('CloneAsNewEventToAs','en',"Clone as new event to %1 as %2");
LngAdd('CloneAsNewEventToAs','cs',"Naklonovat jako novou událost do %1 jako %2");
LngAdd('CloneAsNewRecord','en',"Clone as new record");
LngAdd('CloneAsNewRecord','cs',"Naklonovat jako nový záznam");
LngAdd('_AsPublic','en',"public");
LngAdd('_AsPublic','cs',"veřejné");
LngAdd('WhatIsThis','en',"What is this?");
LngAdd('WhatIsThis','cs',"Co je to?");
LngAdd('EntranceFee','en',"Entrance fee");
LngAdd('EntranceFee','cs',"Vstupné ");
LngAdd('Promoter','en',"Promoter");
LngAdd('Promoter','cs',"Pořadatel");
LngAdd('Amount','en',"Amount");
LngAdd('Amount','cs',"Částka");
LngAdd('Other','en',"Other");
LngAdd('Other','cs',"Ostatní");
LngAdd('Movies','en',"Movies");
LngAdd('Movies','cs',"Kino");
LngAdd('Theatre','en',"Theatre");
LngAdd('Theatre','cs',"Divadlo");
LngAdd('Exhibition','en',"Exhibition");
LngAdd('Exhibition','cs',"Výstava");
LngAdd('Concert','en',"Concert");
LngAdd('Concert','cs',"Koncert");
LngAdd('DanceBall','en',"Ball");
LngAdd('DanceBall','cs',"Ples");
LngAdd('Dance','en',"Dance");
LngAdd('Dance','cs',"Tanec");
LngAdd('SportEvent','en',"Sport event");
LngAdd('SportEvent','cs',"Sportovní událost");
LngAdd('HikingTour','en',"Hiking tour");
LngAdd('HikingTour','cs',"Turistický pochod");
LngAdd('Trip','en',"Trip");
LngAdd('Trip','cs',"Výlet");
LngAdd('EmergenciesAndOutages','en',"Emergencies and outages");
LngAdd('EmergenciesAndOutages','cs',"Havárie a výpadky");
LngAdd('Festival','en',"Festival");
LngAdd('Festival','cs',"Festival");
LngAdd('January','en',"January");
LngAdd('January','cs',"Leden");
LngAdd('February','en',"February");
LngAdd('February','cs',"Únor");
LngAdd('March','en',"March");
LngAdd('March','cs',"Březen");
LngAdd('April','en',"April");
LngAdd('April','cs',"Duben");
LngAdd('May','en',"May");
LngAdd('May','cs',"Květen");
LngAdd('June','en',"June");
LngAdd('June','cs',"Červen");
LngAdd('July','en',"July");
LngAdd('July','cs',"Červenec");
LngAdd('August','en',"August");
LngAdd('August','cs',"Srpen");
LngAdd('September','en',"September");
LngAdd('September','cs',"Září");
LngAdd('October','en',"October");
LngAdd('October','cs',"Říjen");
LngAdd('November','en',"November");
LngAdd('November','cs',"Listopad");
LngAdd('December','en',"December");
LngAdd('December','cs',"Prosinec");
LngAdd('Monday','en',"Monday");
LngAdd('Monday','cs',"Pondělí");
LngAdd('Tuesday','en',"Tuesday");
LngAdd('Tuesday','cs',"Úterý");
LngAdd('Wednesday','en',"Wednesday");
LngAdd('Wednesday','cs',"Středa");
LngAdd('Thursday','en',"Thursday");
LngAdd('Thursday','cs',"Čtvrtek");
LngAdd('Friday','en',"Friday");
LngAdd('Friday','cs',"Pátek");
LngAdd('Saturday','en',"Saturday");
LngAdd('Saturday','cs',"Sobota");
LngAdd('Sunday','en',"Sunday");
LngAdd('Sunday','cs',"Neděle");
LngAdd('NextMonday','en',"Next Monday");
LngAdd('NextMonday','cs',"Příští pondělí");
LngAdd('NextTuesday','en',"Next Tuesday");
LngAdd('NextTuesday','cs',"Příští úterý");
LngAdd('NextWednesday','en',"Next Wednesday");
LngAdd('NextWednesday','cs',"Příští středa");
LngAdd('NextThursday','en',"Next Thursday");
LngAdd('NextThursday','cs',"Příští čtvrtek");
LngAdd('NextFriday','en',"Next Friday");
LngAdd('NextFriday','cs',"Příští pátek");
LngAdd('NextSaturday','en',"Next Saturday");
LngAdd('NextSaturday','cs',"Příští sobota");
LngAdd('NextSunday','en',"Next Sunday");
LngAdd('NextSunday','cs',"Příští neděle");
LngAdd('4Days','en',"4 days");
LngAdd('4Days','cs',"4 dny");
LngAdd('Week','en',"Week");
LngAdd('Week','cs',"Týden");
LngAdd('Month','en',"Month");
LngAdd('Month','cs',"Měsíc");
LngAdd('Day','en',"Day");
LngAdd('Day','cs',"Den");
LngAdd('WorkWeek','en',"Work week");
LngAdd('WorkWeek','cs',"Pracovní týden");
LngAdd('FromTo','en',"From - To");
LngAdd('FromTo','cs',"Od - Do");
LngAdd('Agenda','en',"Agenda");
LngAdd('Agenda','cs',"Agenda");
LngAdd('Mon','en',"Mon");
LngAdd('Mon','cs',"Po");
LngAdd('Tue','en',"Tue");
LngAdd('Tue','cs',"Út");
LngAdd('Wed','en',"Wed");
LngAdd('Wed','cs',"St");
LngAdd('Thu','en',"Thu");
LngAdd('Thu','cs',"Čt");
LngAdd('Fri','en',"Fri");
LngAdd('Fri','cs',"Pá");
LngAdd('Sat','en',"Sat");
LngAdd('Sat','cs',"So");
LngAdd('Sun','en',"Sun");
LngAdd('Sun','cs',"Ne");
LngAdd('OfJanuary','cs',"ledna");
LngAdd('OfFebruary','cs',"února");
LngAdd('OfMarch','cs',"března");
LngAdd('OfApril','cs',"dubna");
LngAdd('OfMay','cs',"května");
LngAdd('OfJune','cs',"června");
LngAdd('OfJuly','cs',"července");
LngAdd('OfAugust','cs',"srpna");
LngAdd('OfSeptember','cs',"září");
LngAdd('OfOctober','cs',"října");
LngAdd('OfNovember','cs',"listopadu");
LngAdd('OfDecember','cs',"prosince");
LngAdd('BoldFont','en',"Bold font");
LngAdd('BoldFont','cs',"Tučné písmo");
LngAdd('ItalicFont','en',"Italic font");
LngAdd('ItalicFont','cs',"Kurzíva");
LngAdd('UnderlineFont','en',"Underline font");
LngAdd('UnderlineFont','cs',"Podtržené písmo");
LngAdd('StrikeThroughFont','en',"Strike-through font");
LngAdd('StrikeThroughFont','cs',"Přeškrtnuté písmo");
LngAdd('Superscript','en',"Superscript");
LngAdd('Superscript','cs',"Horní index");
LngAdd('Subscript','en',"Subscript");
LngAdd('Subscript','cs',"Dolní index");
LngAdd('RemoveFormatting','en',"Remove formatting");
LngAdd('RemoveFormatting','cs',"Odstranit formátování");
LngAdd('InsertUnorderedList','en',"Insert unordered list");
LngAdd('InsertUnorderedList','cs',"Vložit netříděný seznam");
LngAdd('InsertOrderedList','en',"Insert ordered list");
LngAdd('InsertOrderedList','cs',"Vložit tříděný seznam");
LngAdd('InsertHorizontalRule','en',"Insert horizontal rule");
LngAdd('InsertHorizontalRule','cs',"Vložit vodorovný oddělovač");
LngAdd('InsertImage','en',"Insert image");
LngAdd('InsertImage','cs',"Vložit obrázek");
LngAdd('InsertImageFromGallery','en',"Insert image from gallery");
LngAdd('InsertImageFromGallery','cs',"Vložit obrázek z galerie");
LngAdd('InsertImageFromMyComputer','en',"Insert image from my computer");
LngAdd('InsertImageFromMyComputer','cs',"Vložit obrázek z mého počítače");
LngAdd('Target','en',"Target");
LngAdd('Target','cs',"Cíl");
LngAdd('LeftAlign','en',"Left align");
LngAdd('LeftAlign','cs',"Zarovnat odstavec vlevo");
LngAdd('RightAlign','en',"Right align");
LngAdd('RightAlign','cs',"Zarovat odstavec vpravo");
LngAdd('BlockAlign','en',"Block align");
LngAdd('BlockAlign','cs',"Zarovnat odstavec do bloku");
LngAdd('CenterAlign','en',"Center align");
LngAdd('CenterAlign','cs',"Zarovnat odstavec na střed");
LngAdd('Link','en',"Link");
LngAdd('Link','cs',"Odkaz");
LngAdd('Hyperlink','en',"Hyperlink");
LngAdd('Hyperlink','cs',"Hypertextový odkaz");
LngAdd('InsertHyperlink','en',"Insert hyperlink");
LngAdd('InsertHyperlink','cs',"Vložit hypertextový odkaz");
LngAdd('Table','en',"Table");
LngAdd('Table','cs',"Tabulka");
LngAdd('InsertTable','en',"Insert table");
LngAdd('InsertTable','cs',"Vložit tabulku");
LngAdd('klecebendaZadejteVasiPoptavku','cs',"Zadejte Vaši poptávku");
LngAdd('klecebendaRozmery','cs',"Rozměry (š-v-h v centimetrech)");
LngAdd('klecebendaPopisZakazky','cs',"Popis zakázky");
LngAdd('klecebendaPriloha','cs',"Příloha (např. nákres)");
LngAdd('klecebendaOdeslat','cs',"Odeslat poptávku");
function LngAdd($name,$lng,$text) {
    global $TEXTS;
    $text = str_replace("'","&#39;",$text);
    if(IsSet($TEXTS[$name][$lng])) {
        AddError("LngAdd error: Combination of \"$name\" and \"$lng\" already exists.");}
    else {
        $TEXTS[$name][$lng] = $text;}}
function Lng() {
    global $TEXTS, $MTPS;
    $args_count = func_num_args();
    if($args_count > 0 && $MTPS->Language != "") {
        $lng = $MTPS->Language;
        $name = func_get_arg(0);
        if(IsSet($TEXTS[$name])) {
            if(IsSet($TEXTS[$name][$lng])) { $text = $TEXTS[$name][$lng]; }
            else {
                if(IsSet($TEXTS[$name][$MTPS->DefaultLanguage])) { $text = $TEXTS[$name][$MTPS->DefaultLanguage]; }
                else if(IsSet($TEXTS[$name]['cs'])) { $text = $TEXTS[$name]['cs']; }
                else if(IsSet($TEXTS[$name]['en'])) { $text = $TEXTS[$name]['en']; }
                else if(IsSet($TEXTS[$name]['de'])) { $text = $TEXTS[$name]['de']; }
                else {
                    WriteLog("Translation ERR (Lng): name = '".$name."', lng = '".$lng."', DefaultLanguage = '".$MTPS->DefaultLanguage."'");
                    $text = "Translation error (1): String \"$name\" doesn&#39;t exists!";}}}
        else {
            $text = "(!)$name";}
        if($args_count > 1 && IsSet($text)) {
            for($aa=0; $aa<$args_count-1; $aa++) {
                $str = sprintf("%%%d",$args_count-$aa-1);
                $pos = $args_count-$aa-1;
                $dynamic_text = func_get_arg($pos);
                $text = str_replace($str,$dynamic_text,$text);}}
        return $text;}
    return "Translation error (3)!";}
function LngEx() {
    global $TEXTS, $MTPS;
    $args_count = func_num_args();
    if($args_count > 0) {
        $lng = func_get_arg(0);
        if($args_count > 1 && $lng != "") {
            $name = func_get_arg(1);
            if(IsSet($TEXTS[$name])) {
                if(IsSet($TEXTS[$name][$lng])) { $text = $TEXTS[$name][$lng]; }
                else {
                    if(IsSet($TEXTS[$name][$MTPS->DefaultLanguage])) { $text = $TEXTS[$name][$MTPS->DefaultLanguage]; }
                    else if(IsSet($TEXTS[$name]['cs'])) { $text = $TEXTS[$name]['cs']; }
                    else if(IsSet($TEXTS[$name]['en'])) { $text = $TEXTS[$name]['en']; }
                    else if(IsSet($TEXTS[$name]['de'])) { $text = $TEXTS[$name]['de']; }
                    else {
                        WriteLog("Translation ERR (LngEx): name = '".$name."', lng = '".$lng."', DefaultLanguage = '".$MTPS->DefaultLanguage."'");
                        $text = "Translation error (1): String \"$name\" doesn&#39;t exists!";}}}
            else {
                $text = "(!)$name";}
            if($args_count > 2 && IsSet($text)) {
                for($aa=0; $aa<$args_count-2; $aa++) {
                    $str = sprintf("%%%d",$args_count-$aa-1);
                    $pos = $args_count-$aa-1;
                    $dynamic_text = func_get_arg($pos);
                    $text = str_replace($str,$dynamic_text,$text);}}
            return $text;}
        return "Translation error (3)!";}
    return "Translation error (4)!";}
class SMTP {
    public $SMTP_PORT = 25;
    public $CRLF = "\r\n";
    public $do_debug;
    public $Debugoutput = "echo";
    public $do_verp = false;
    public $Timeout = 15;
    public $Timelimit = 30;
    public $Version = '5.2.4';
    private $smtp_conn;
    private $error;
    private $helo_rply;
    private function edebug($str) {
        if ($this->Debugoutput == "error_log") {
            error_log($str);
        } else {
            echo $str;}}
    public function __construct() {
        $this->smtp_conn = 0;
        $this->error = null;
        $this->helo_rply = null;
        $this->do_debug = 0;}
    public function Connect($host, $port = 0, $tval = 30) {
        $this->error = null;
        if($this->connected()) {
            $this->error = array("error" => "Already connected to a server");
            return false;}
        if(empty($port)) {
            $port = $this->SMTP_PORT;}
        $this->smtp_conn = @fsockopen($host,
            $port,
            $errno,
            $errstr,
            $tval);
        if(empty($this->smtp_conn)) {
            $this->error = array("error" => "Failed to connect to server",
                "errno" => $errno,
                "errstr" => $errstr);
            if($this->do_debug >= 1) {
                $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": $errstr ($errno)" . $this->CRLF . '<br />');}
            return false;}
        if(substr(PHP_OS, 0, 3) != "WIN") {
            $max = ini_get('max_execution_time');
            if ($max != 0 && $tval > $max) {
                @set_time_limit($tval);}
            stream_set_timeout($this->smtp_conn, $tval, 0);}
        $announce = $this->get_lines();
        if($this->do_debug >= 2) {
            $this->edebug("SMTP -> FROM SERVER:" . $announce . $this->CRLF . '<br />');}
        return true;}
    public function StartTLS() {
        $this->error = null; # to avoid confusion
        if(!$this->connected()) {
            $this->error = array("error" => "Called StartTLS() without being connected");
            return false;}
        fputs($this->smtp_conn,"STARTTLS" . $this->CRLF);
        $rply = $this->get_lines();
        $code = substr($rply,0,3);
        if($this->do_debug >= 2) {
            $this->edebug("SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />');}
        if($code != 220) {
            $this->error =
                array("error" => "STARTTLS not accepted from server",
                    "smtp_code" => $code,
                    "smtp_msg" => substr($rply,4));
            if($this->do_debug >= 1) {
                $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />');}
            return false;}
        if(!stream_socket_enable_crypto($this->smtp_conn, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) {
            return false;}
        return true;}
    public function Authenticate($username, $password, $authtype='LOGIN', $realm='', $workstation='') {
        if (empty($authtype)) {
            $authtype = 'LOGIN';}
        switch ($authtype) {
            case 'PLAIN':
                fputs($this->smtp_conn,"AUTH PLAIN" . $this->CRLF);
                $rply = $this->get_lines();
                $code = substr($rply,0,3);
                if($code != 334) {
                    $this->error =
                        array("error" => "AUTH not accepted from server",
                            "smtp_code" => $code,
                            "smtp_msg" => substr($rply,4));
                    if($this->do_debug >= 1) {
                        $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />');}
                    return false;}
                fputs($this->smtp_conn, base64_encode("\0".$username."\0".$password) . $this->CRLF);
                $rply = $this->get_lines();
                $code = substr($rply,0,3);
                if($code != 235) {
                    $this->error =
                        array("error" => "Authentication not accepted from server",
                            "smtp_code" => $code,
                            "smtp_msg" => substr($rply,4));
                    if($this->do_debug >= 1) {
                        $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />');}
                    return false;}
                break;
            case 'LOGIN':
                fputs($this->smtp_conn,"AUTH LOGIN" . $this->CRLF);
                $rply = $this->get_lines();
                $code = substr($rply,0,3);
                if($code != 334) {
                    $this->error =
                        array("error" => "AUTH not accepted from server",
                            "smtp_code" => $code,
                            "smtp_msg" => substr($rply,4));
                    if($this->do_debug >= 1) {
                        $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />');}
                    return false;}
                fputs($this->smtp_conn, base64_encode($username) . $this->CRLF);
                $rply = $this->get_lines();
                $code = substr($rply,0,3);
                if($code != 334) {
                    $this->error =
                        array("error" => "Username not accepted from server",
                            "smtp_code" => $code,
                            "smtp_msg" => substr($rply,4));
                    if($this->do_debug >= 1) {
                        $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />');}
                    return false;}
                fputs($this->smtp_conn, base64_encode($password) . $this->CRLF);
                $rply = $this->get_lines();
                $code = substr($rply,0,3);
                if($code != 235) {
                    $this->error =
                        array("error" => "Password not accepted from server",
                            "smtp_code" => $code,
                            "smtp_msg" => substr($rply,4));
                    if($this->do_debug >= 1) {
                        $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />');}
                    return false;}
                break;
            case 'NTLM':
                require_once('ntlm_sasl_client.php');
                $temp = new stdClass();
                $ntlm_client = new ntlm_sasl_client_class;
                if(! $ntlm_client->Initialize($temp)){
                    $this->error = array("error" => $temp->error);
                    if($this->do_debug >= 1) {
                        $this->edebug("You need to enable some modules in your php.ini file: " . $this->error["error"] . $this->CRLF);}
                    return false;}
                $msg1 = $ntlm_client->TypeMsg1($realm, $workstation);
                fputs($this->smtp_conn,"AUTH NTLM " . base64_encode($msg1) . $this->CRLF);
                $rply = $this->get_lines();
                $code = substr($rply,0,3);
                if($code != 334) {
                    $this->error =
                        array("error" => "AUTH not accepted from server",
                            "smtp_code" => $code,
                            "smtp_msg" => substr($rply,4));
                    if($this->do_debug >= 1) {
                        $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF);}
                    return false;}
                $challange = substr($rply,3);
                $challange = base64_decode($challange);
                $ntlm_res = $ntlm_client->NTLMResponse(substr($challange,24,8),$password);
                $msg3 = $ntlm_client->TypeMsg3($ntlm_res,$username,$realm,$workstation);
                fputs($this->smtp_conn, base64_encode($msg3) . $this->CRLF);
                $rply = $this->get_lines();
                $code = substr($rply,0,3);
                if($code != 235) {
                    $this->error =
                        array("error" => "Could not authenticate",
                            "smtp_code" => $code,
                            "smtp_msg" => substr($rply,4));
                    if($this->do_debug >= 1) {
                        $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF);}
                    return false;}
                break;}
        return true;}
    public function Connected() {
        if(!empty($this->smtp_conn)) {
            $sock_status = socket_get_status($this->smtp_conn);
            if($sock_status["eof"]) {
                if($this->do_debug >= 1) {
                    $this->edebug("SMTP -> NOTICE:" . $this->CRLF . "EOF caught while checking if connected");}
                $this->Close();
                return false;}
            return true;}
        return false;}
    public function Close() {
        $this->error = null;
        $this->helo_rply = null;
        if(!empty($this->smtp_conn)) {
            fclose($this->smtp_conn);
            $this->smtp_conn = 0;}}
    public function Data($msg_data) {
        $this->error = null;
        if(!$this->connected()) {
            $this->error = array(
                "error" => "Called Data() without being connected");
            return false;}
        fputs($this->smtp_conn,"DATA" . $this->CRLF);
        $rply = $this->get_lines();
        $code = substr($rply,0,3);
        if($this->do_debug >= 2) {
            $this->edebug("SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />');}
        if($code != 354) {
            $this->error =
                array("error" => "DATA command not accepted from server",
                    "smtp_code" => $code,
                    "smtp_msg" => substr($rply,4));
            if($this->do_debug >= 1) {
                $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />');}
            return false;}
        $msg_data = str_replace("\r\n","\n",$msg_data);
        $msg_data = str_replace("\r","\n",$msg_data);
        $lines = explode("\n",$msg_data);
        $field = substr($lines[0],0,strpos($lines[0],":"));
        $in_headers = false;
        if(!empty($field) && !strstr($field," ")) {
            $in_headers = true;}
        $max_line_length = 998;
        while(list(,$line) = @each($lines)) {
            $lines_out = null;
            if($line == "" && $in_headers) {
                $in_headers = false;}
            while(strlen($line) > $max_line_length) {
                $pos = strrpos(substr($line,0,$max_line_length)," ");
                if(!$pos) {
                    $pos = $max_line_length - 1;
                    $lines_out[] = substr($line,0,$pos);
                    $line = substr($line,$pos);
                } else {
                    $lines_out[] = substr($line,0,$pos);
                    $line = substr($line,$pos + 1);}
                if($in_headers) {
                    $line = "\t" . $line;}}
            $lines_out[] = $line;
            while(list(,$line_out) = @each($lines_out)) {
                if(strlen($line_out) > 0)
                {
                    if(substr($line_out, 0, 1) == ".") {
                        $line_out = "." . $line_out;}}
                fputs($this->smtp_conn,$line_out . $this->CRLF);}}
        fputs($this->smtp_conn, $this->CRLF . "." . $this->CRLF);
        $rply = $this->get_lines();
        $code = substr($rply,0,3);
        if($this->do_debug >= 2) {
            $this->edebug("SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />');}
        if($code != 250) {
            $this->error =
                array("error" => "DATA not accepted from server",
                    "smtp_code" => $code,
                    "smtp_msg" => substr($rply,4));
            if($this->do_debug >= 1) {
                $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />');}
            return false;}
        return true;}
    public function Hello($host = '') {
        $this->error = null;
        if(!$this->connected()) {
            $this->error = array(
                "error" => "Called Hello() without being connected");
            return false;}
        if(empty($host)) {
            $host = "localhost";}
        if(!$this->SendHello("EHLO", $host)) {
            if(!$this->SendHello("HELO", $host)) {
                return false;}}
        return true;}
    private function SendHello($hello, $host) {
        fputs($this->smtp_conn, $hello . " " . $host . $this->CRLF);
        $rply = $this->get_lines();
        $code = substr($rply,0,3);
        if($this->do_debug >= 2) {
            $this->edebug("SMTP -> FROM SERVER: " . $rply . $this->CRLF . '<br />');}
        if($code != 250) {
            $this->error =
                array("error" => $hello . " not accepted from server",
                    "smtp_code" => $code,
                    "smtp_msg" => substr($rply,4));
            if($this->do_debug >= 1) {
                $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />');}
            return false;}
        $this->helo_rply = $rply;
        return true;}
    public function Mail($from) {
        $this->error = null;
        if(!$this->connected()) {
            $this->error = array(
                "error" => "Called Mail() without being connected");
            return false;}
        $useVerp = ($this->do_verp ? " XVERP" : "");
        fputs($this->smtp_conn,"MAIL FROM:<" . $from . ">" . $useVerp . $this->CRLF);
        $rply = $this->get_lines();
        $code = substr($rply,0,3);
        if($this->do_debug >= 2) {
            $this->edebug("SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />');}
        if($code != 250) {
            $this->error =
                array("error" => "MAIL not accepted from server",
                    "smtp_code" => $code,
                    "smtp_msg" => substr($rply,4));
            if($this->do_debug >= 1) {
                $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />');}
            return false;}
        return true;}
    public function Quit($close_on_error = true) {
        $this->error = null;
        if(!$this->connected()) {
            $this->error = array(
                "error" => "Called Quit() without being connected");
            return false;}
        fputs($this->smtp_conn,"quit" . $this->CRLF);
        $byemsg = $this->get_lines();
        if($this->do_debug >= 2) {
            $this->edebug("SMTP -> FROM SERVER:" . $byemsg . $this->CRLF . '<br />');}
        $rval = true;
        $e = null;
        $code = substr($byemsg,0,3);
        if($code != 221) {
            $e = array("error" => "SMTP server rejected quit command",
                "smtp_code" => $code,
                "smtp_rply" => substr($byemsg,4));
            $rval = false;
            if($this->do_debug >= 1) {
                $this->edebug("SMTP -> ERROR: " . $e["error"] . ": " . $byemsg . $this->CRLF . '<br />');}}
        if(empty($e) || $close_on_error) {
            $this->Close();}
        return $rval;}
    public function Recipient($to) {
        $this->error = null;
        if(!$this->connected()) {
            $this->error = array(
                "error" => "Called Recipient() without being connected");
            return false;}
        fputs($this->smtp_conn,"RCPT TO:<" . $to . ">" . $this->CRLF);
        $rply = $this->get_lines();
        $code = substr($rply,0,3);
        if($this->do_debug >= 2) {
            $this->edebug("SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />');}
        if($code != 250 && $code != 251) {
            $this->error =
                array("error" => "RCPT not accepted from server",
                    "smtp_code" => $code,
                    "smtp_msg" => substr($rply,4));
            if($this->do_debug >= 1) {
                $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />');}
            return false;}
        return true;}
    public function Reset() {
        $this->error = null;
        if(!$this->connected()) {
            $this->error = array(
                "error" => "Called Reset() without being connected");
            return false;}
        fputs($this->smtp_conn,"RSET" . $this->CRLF);
        $rply = $this->get_lines();
        $code = substr($rply,0,3);
        if($this->do_debug >= 2) {
            $this->edebug("SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />');}
        if($code != 250) {
            $this->error =
                array("error" => "RSET failed",
                    "smtp_code" => $code,
                    "smtp_msg" => substr($rply,4));
            if($this->do_debug >= 1) {
                $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />');}
            return false;}
        return true;}
    public function SendAndMail($from) {
        $this->error = null;
        if(!$this->connected()) {
            $this->error = array(
                "error" => "Called SendAndMail() without being connected");
            return false;}
        fputs($this->smtp_conn,"SAML FROM:" . $from . $this->CRLF);
        $rply = $this->get_lines();
        $code = substr($rply,0,3);
        if($this->do_debug >= 2) {
            $this->edebug("SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />');}
        if($code != 250) {
            $this->error =
                array("error" => "SAML not accepted from server",
                    "smtp_code" => $code,
                    "smtp_msg" => substr($rply,4));
            if($this->do_debug >= 1) {
                $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />');}
            return false;}
        return true;}
    public function Turn() {
        $this->error = array("error" => "This method, TURN, of the SMTP ".
            "is not implemented");
        if($this->do_debug >= 1) {
            $this->edebug("SMTP -> NOTICE: " . $this->error["error"] . $this->CRLF . '<br />');}
        return false;}
    public function getError() {
        return $this->error;}
    private function get_lines() {
        $data = "";
        $endtime = 0;
        if (!is_resource($this->smtp_conn)) {
            return $data;}
        stream_set_timeout($this->smtp_conn, $this->Timeout);
        if ($this->Timelimit > 0) {
            $endtime = time() + $this->Timelimit;}
        while(is_resource($this->smtp_conn) && !feof($this->smtp_conn)) {
            $str = @fgets($this->smtp_conn,515);
            if($this->do_debug >= 4) {
                $this->edebug("SMTP -> get_lines(): \$data was \"$data\"" . $this->CRLF . '<br />');
                $this->edebug("SMTP -> get_lines(): \$str is \"$str\"" . $this->CRLF . '<br />');}
            $data .= $str;
            if($this->do_debug >= 4) {
                $this->edebug("SMTP -> get_lines(): \$data is \"$data\"" . $this->CRLF . '<br />');}
            if(substr($str,3,1) == " ") { break; }
            $info = stream_get_meta_data($this->smtp_conn);
            if ($info['timed_out']) {
                if($this->do_debug >= 4) {
                    $this->edebug("SMTP -> get_lines(): timed-out (" . $this->Timeout . " seconds) <br />");}
                break;}
            if ($endtime) {
                if (time() > $endtime) {
                    if($this->do_debug >= 4) {
                        $this->edebug("SMTP -> get_lines(): timelimit reached (" . $this->Timelimit . " seconds) <br />");}
                    break;}}}
        return $data;}}
if (version_compare(PHP_VERSION, '5.0.0', '<') ) exit("Sorry, this version of PHPMailer will only run on PHP version 5 or greater!\n");
class MYSQL {
    public $Connection = 0;
    private $Host;
    private $User;
    private $Pass;
    public $Name;
    public function Connect($host,$username,$password,$db_name,$port,$verbose=false) {
        global $MTPS;
        if($verbose) { AddError("[MYSQL::Connect]"); }
        if(!$port) { $port=3306;};
        
        $this->Connection = new mysqli($host,$username,$password,$db_name,$port);
        if($this->Connection->connect_error || $db_name == "") {
            WriteLog('[DB::Connect] Connect error ('.$this->Connection->connect_errno.') '.$this->Connection->connect_error);
            die('Connect error ('.$this->Connection->connect_errno.') '.$this->Connection->connect_error);}
        $db_name_secured = DBText($db_name);
        $this->Connection->select_db($db_name_secured);
        if($result = $this->Connection->query("SELECT DATABASE()")) {
            $row = $result->fetch_row();
            $result->free_result();
            if($row[0] != $db_name_secured) {
                $this->Request("CREATE DATABASE IF NOT EXISTS `".$db_name_secured."` CHARACTER SET = 'utf8' COLLATE = 'utf8_general_ci'");
                $this->Request("SET NAMES utf8");
                $this->Connection->select_db($db_name_secured);
                if($result = $this->Connection->query("SELECT DATABASE()")) {
                    $row = $result->fetch_row();
                    $result->free_result();
                    if($row[0] != $db_name_secured) {
                        WriteLog('Connect error: Can\'t connect to the "'.$db_name_secured.'" MySQL database.');
                        die('Connect error: Can\'t connect to the "'.$db_name_secured.'" MySQL database.');}}}}
        $this->Host = $host;
        $this->User = $username;
        $this->Pass = $password;
        $this->Name = $db_name;
        $this->Connection->query("SET NAMES utf8");
        if($verbose) { AddError("[MYSQL::Connected]"); }}
    public function Disconnect($verbose=false) {
        if($verbose) { AddError("[MYSQL::Disconnect]"); }
        $this->Connection->close();}
    public function Request($request) {
        if(($result = $this->Connection->query($request,MYSQLI_STORE_RESULT))) {
            if(is_object($result)) { $result->close(); }
            return true;}
        WriteLog("[MYSQL::Request] ".$this->Connection->error." Request: ".$request);
        AddError("[MYSQL::Request] ".$this->Connection->error);
        return false;}
    public function Request2($request) {
        if(($result = $this->Connection->query($request,MYSQLI_STORE_RESULT))) {
            return $result;}
        WriteLog("[MYSQL::Request] ".$this->Connection->error." Request: ".$request);
        AddError("[MYSQL::Request] ".$this->Connection->error);
        return false;}
    public function TableName($table_name) {
        global $TABLE;
        if(IsSet($TABLE[$table_name])) {
            return $TABLE[$table_name]['TABLE_FullName'];}
        return "____NON_EXISTING_TABLE____";}
    function Select($table_name,$where,&$count=0,$order_by="",$limit="",$group_by="",$select_deleted=false,$outfile="",$pass_two=false) {
        global $TABLE, $MTPS;
        $where_original = $where;
        $where = str_replace(" OR )","')",$where);
        $where = str_replace("))')",")))",$where);
        $where = str_replace(" OR ')",")",$where);
        if(IsSet($TABLE[$table_name])) {
            if($outfile == "") {
                $FROM = "FROM";}
            else {
                $FROM = "INTO OUTFILE '".DBText($outfile)."' FROM";}
            $full_table_name = $TABLE[$table_name]['TABLE_FullName'];
            if($select_deleted) {
                $request = "SELECT * $FROM `".DBText($full_table_name)."` WHERE $where";}
            else {
                if($where != "") { $where.= " AND "; }
                $request = "SELECT * $FROM `".DBText($full_table_name)."` WHERE $where`Deleted`=0";}
            if($group_by != "") { $request.= " GROUP BY ".$group_by; }
            if($order_by != "") { $request.= " ORDER BY ".$order_by; }
            if($limit != "") { $request.= " LIMIT ".$limit; }
            if($outfile == "") {
                //if ($table_name == "odoprag_cars")
                //error_log("$table_name,$request") ;
                $this->SaveDBRequest($table_name,$request);}
            if(($result = $this->Connection->query($request,MYSQLI_STORE_RESULT))) {
                if($outfile == "") {
                    $pos = 0;
                    $rows = array();
                    while(($rows[$pos] = $result->fetch_object())) {
                        if($pos == 100000) { WriteLog("100.000 rows in table '".$table_name."', where = ".$where); }
                        $pos++;}
                    $count = $result->num_rows;
                    $result->close();
                    if($rows[$count] == null) { $rows = array_slice($rows,0,$count); }
                    return $rows;}
                else {
                    return true;}}
            WriteLog("[MYSQL::Select] pass_two: ".BoolToInt($pass_two));
            WriteLog("[MYSQL::Select] ErrNo: ".$this->Connection->errno."; ".$this->Connection->error." Request: ".$request);
            AddError("[MYSQL::Select] ErrNo: ".$this->Connection->errno."; ".$this->Connection->error);
            if(!$pass_two) {
                if($this->Connection->errno == 2006) {
                    $this->Disconnect(true);
                    $this->Connect($MTPS->MySQL_Host,$MTPS->MySQL_User,$MTPS->MySQL_Pass,$MTPS->MySQL_Name,$MTPS->MySQL_Port,true);
                    AddError("[MYSQL::Select] Performing SELECT again.");
                    return $this->Select($table_name,$where_original,$count,$order_by,$limit,$group_by,$select_deleted,$outfile,true);}}
            $count = 0;}
        else {
            $callers=debug_backtrace();
            AddError("[MYSQL::Select] Table \"".XSS($table_name)."\" is not defined! Caller: ".$callers[1]['function'].".");}
        return false;}
    function SelectTree($table_name,$where,$parent_id,$tree_pos,&$count,$order_by="",$limit="",$group_by="") {
        global $TABLE, $MTPS;
        $count = 0;
        $where2 = $where;
        if($where2 != "") { $where2.= " AND "; }
        $where2.= "`ParentID`=".DBText($parent_id);
        if(($rows = $this->Select($table_name,$where2,$rows_count,$order_by,$limit,$group_by)) !== false) {
            if($rows_count > 0) {
                for($aa=0; $aa<$rows_count; $aa++) {
                    $items[$count] = $rows[$aa];
                    $items[$count]->TreePos = $tree_pos;
                    $count++;
                    if(($items2 = $this->SelectTree($table_name,$where,$rows[$aa]->ID,$tree_pos+1,$count2,$order_by,$limit,$group_by)) !== false && $count2 > 0) {
                        for($bb=0; $bb<$count2; $bb++) {
                            $items[$count] = $items2[$bb];
                            $count++;}}}
                return $items;}}
        else {
            $callers=debug_backtrace();
            AddError("[MYSQL::SelectTree] Error accessing table \"".XSS($table_name)."\"! Caller: ".$callers[1]['function'].".");}
        return false;}
    function Update($table_name,$set,$where,&$response="",$deleted_too=false) {
        global $TABLE;
        $response = "";
        if(!$deleted_too) { $where.= " AND `Deleted`=0"; }
        $request = "UPDATE `".DBText($TABLE[$table_name]['TABLE_FullName'])."` SET $set `Changed`=".Time()." WHERE $where";
        $this->SaveDBRequest($table_name,$request);
        if($this->Connection->query($request,MYSQLI_STORE_RESULT)) {
            if($this->Connection->affected_rows == 0) { return true; }
            return $this->Connection->affected_rows;}
        $response = AddError("[MYSQL::Update] ".$this->Connection->error);
        return false;}
    function Replace($table_name,$data=false,&$response="") {
        global $TABLE;
        $columns = "";
        $vals = "";
        $count = 0;
        if(IsSet($data) && $data != false) {
            foreach($data as $key => $value) {
                if($key != "") {
                    if($count > 0) { $columns.= ","; $vals.= ","; }
                    $columns.= "`".DBText($key)."`";
                    $vals.= "'".DBText($value)."'";
                    $count++;}}}
        if($count > 0) { $columns.= ","; $vals.= ","; }
        $columns.= "`Created`,`Changed`";
        $vals.= Time().",".Time();
        $request = "REPLACE INTO `".DBText($TABLE[$table_name]['TABLE_FullName'])."` ($columns) VALUES($vals);";
        $this->SaveDBRequest($table_name,$request);
        if($this->Connection->query($request,MYSQLI_STORE_RESULT)) {
            return $this->Connection->insert_id;}
        AddError("[MYSQL::Replace] ".$this->Connection->error);
        $response = "[MYSQL::Replace] ".$this->Connection->error;
        return false;}
    function Delete($table_name,$where,&$response="") {
        global $TABLE;
        $time = DBText(Time());
        $where = trim($where);
        if($where != "") { $where.= " AND "; }
        $where.= "`Deleted`=0";
        $request = "UPDATE `".DBText($TABLE[$table_name]['TABLE_FullName'])."` SET `Deleted`=".$time.", `Changed`=".$time." WHERE ".$where;
        $this->SaveDBRequest($table_name,$request);
        if($this->Connection->query($request,MYSQLI_STORE_RESULT)) {
            if($this->Connection->affected_rows == 0) { return true; }
            return $this->Connection->affected_rows;}
        $response = AddError("[MYSQL::Delete] ".$this->Connection->error);
        return false;}
    function Insert($table_name,$data=false,&$response="") {
        global $TABLE;
        $columns = "";
        $vals = "";
        $count = 0;
        if(IsSet($data) && $data != false) {
            foreach($data as $key => $value) {
                if($key != "") {
                    if($count > 0) { $columns.= ","; $vals.= ","; }
                    $columns.= "`".DBText($key)."`";
                    $vals.= "'".DBText($value)."'";
                    $count++;}}}
        if($count > 0) { $columns.= ","; $vals.= ","; }
        $columns.= "`Created`,`Changed`";
        $vals.= Time().",".Time();
        $request = "INSERT INTO `".DBText($TABLE[$table_name]['TABLE_FullName'])."` ($columns) VALUES($vals);";
        $this->SaveDBRequest($table_name,$request);
        if($this->Connection->query($request,MYSQLI_STORE_RESULT)) {
            return $this->Connection->insert_id;}
        $errstr = "[MYSQL::Insert] ".$this->Connection->error." Table: ".$table_name." Request: ".$request;
        WriteLog($errstr);
        AddError($errstr);
        $response = $errstr;
        return false;}
    function EraseTable($table_name) {
        global $TABLE;
        $request = "TRUNCATE `".DBText($TABLE[$table_name]['TABLE_FullName'])."`";
        return $this->Connection->query($request,MYSQLI_STORE_RESULT);}
    public function SaveDBRequest($table_name,$request) {
        global $MTPS;
        if($MTPS->SaveDBRequests && $table_name != "DBRequests") {
            if(IsSet($data)) { UnSet($data); }
            $data['IP'] = $MTPS->IP;
            $data['Request'] = $request;
            $this->Insert("DBRequests",$data);}}
    function SelectSuperiorTree($table_name,$row,$treepos,&$count,$order_by="") {
        global $TABLE, $MTPS;
        $count = 0;
        $list = array();
        $list[$count] = $row;
        $count++;
        $where = "`ID`=".DBText($row->ParentID);
        if(($rows = $this->Select($table_name,$where,$rows_count,$order_by,"1","")) !== false && $rows_count > 0) {
            $parents2 = $this->SelectSuperiorTree($table_name,$rows[0],$treepos+1,$count2);
            for($aa=0; $aa<$count2; $aa++) {
                $list[$count] = $parents2[$aa];
                $count++;}}
        if($treepos == 0) {
            $newlist = array();
            for($aa=0; $aa<$count; $aa++) {
                $newlist[$aa] = $list[$count-$aa-1];}
            return $newlist;}
        return $list;}
    public function ListFields($table_name) {
        global $TABLE;
        if(IsSet($TABLE[$table_name])) {
            $full_table_name = $TABLE[$table_name]['TABLE_FullName'];
            $request = "SELECT * FROM ".$full_table_name." LIMIT 1";
            if(($result = $this->Connection->query($request,MYSQLI_STORE_RESULT))) {
                return $result;}
            WriteLog("[MYSQL::Request] ".$this->Connection->error." Request: ".$request);
            AddError("[MYSQL::Request] ".$this->Connection->error);}
        return false;}}
$DB = new MYSQL;
#$DB->Connect($MTPS->MySQL_Host,$MTPS->MySQL_User,$MTPS->MySQL_Pass,$MTPS->MySQL_Name);

$DB->Connect($MTPS->MySQL_Host,$MTPS->MySQL_User,$MTPS->MySQL_Pass,$MTPS->MySQL_Name,$MTPS->MySQL_Port);
function testLoginString($user_login_string,&$report="") {
    global $MTPS;
    $ok = false; $ok_id = false; $ok_username = false; $ok_email = false;
    if(!$ok && $MTPS->LoginByID) {
        $ok = is_numeric($user_login_string);
        $ok_id = $ok;}
    if(!$ok && $MTPS->LoginByUsername) {
        $ok = TestUsername($user_login_string,$report_username);
        $ok_username = $ok;}
    if(!$ok && $MTPS->LoginByEmail) {
        $ok = TestEmail($user_login_string,$report_email);
        $ok_email = $ok;}
    if(!$ok) {
        $report = "<h7>".Lng("UserLoginStringError")."</h7>";
        $lines = 0;
        if($MTPS->LoginByID) { if($lines) { $report.= "<br />"; } $report.= "<u>".Lng('TestLoginIfID')."</u><br />".Lng('UserIdMustBeNumber'); $lines++; }
        if($MTPS->LoginByUsername) { if($lines) { $report.= "<br />"; } $report.= "<u>".Lng('TestLoginIfUsername')."</u><br />".$report_username; $lines++; }
        if($MTPS->LoginByEmail) { if($lines) { $report.= "<br />"; } $report.= "<u>".Lng('TestLoginIfEmail')."</u><br />".$report_email; }}
    return $ok;}
function TestEmail($email,&$report="") {
    $report = "";
    if(strlen($email) < 6) { $report = Lng('TestEmailTooShort',XSS($email)); return false; }
    if(strlen($email) > 128) { $report = Lng('TestEmailTooLong',XSS($email)); return false; }
    $pos = strpos($email,"@");
    if($pos !== false) {
        $pos2 = strpos($email,"@",($pos+1));
        if($pos2 === false) {
            $posM = strpos($email," ");
            if($posM === false) {
                $posT = strpos($email,".",$pos);
                if($posT !== false) {
                    return true;}
                else {
                    $report = Lng('TestEmailDotAfterAtMissing'); return false;}}
            else {
                $report = Lng('TestEmailSpace'); return false;}}
        else {
            $report = Lng('TestEmailTooMuchAts'); return false;}}
    else {
        $report = Lng('TestEmailAtMissing'); return false;}
    return true;}
function TestUsername($username,&$report="") {
    $report = "";
    if(strlen($username) < 3) { $report = Lng('TestUsernameTooShort',XSS($username)); return false; }
    if(strlen($username) > 128) { $report = Lng('TestUsernameTooLong',XSS($username)); return false; }
    $username = strtolower($username);
    $err = false;
    $pos = strpos($username," ");
    if($pos !== false) { $report = Lng('TestUsernameSpace'); return false; }
    $pos = strpos($username,"--");
    if($pos !== false) { $report = Lng('TestUsernameTooMuchHyphens'); return false; }
    for($aa=0; $aa<strlen($username); $aa++) {
        $zn = ord($username[$aa]);
        if($zn < 48 || $zn > 57) {
            if($zn < 97 || $zn > 122) {
                if($zn != ord('-') && $zn != ord('.') & $zn != ord('_')) {
                    $err = true; break;}}}}
    if($err) {
        $report = Lng('TestUsernameBadChars',XSS($username));
        return false;}
    return true;}
function TestPassword($password,&$report="") {
    $report = "";
    if(strlen($password) < 6) { $report = Lng('TestPasswordTooShort'); return false; }
    if(strlen($password) > 128) { $report = Lng('TestPasswordTooLong'); return false; }
    $password = strtolower($password);
    $err = false;
    for($aa=0; $aa<strlen($password); $aa++) {
        $zn = ord($password[$aa]);
        if($zn < 48 || $zn > 57) {
            if($zn < 97 || $zn > 122) {
                if($zn != 32 && $zn != ord('-') && $zn != ord('!') && $zn != ord('?') && $zn != ord('&') && $zn != ord('+') && $zn != ord('.') & $zn != ord('_')) {
                    $err = true; break;}}}}
    if($err) {
        $report = Lng('TestPasswordBadChars');
        return false;}
    return true;}
function TestNewPassword($password,&$report="") {
    $report = "";
    if(strlen($password) < 6) { $report = Lng('TestNewPasswordTooShort'); return false; }
    if(strlen($password) > 128) { $report = Lng('TestNewPasswordTooLong'); return false; }
    $password = strtolower($password);
    $err = false;
    for($aa=0; $aa<strlen($password); $aa++) {
        $zn = ord($password[$aa]);
        if($zn < 48 || $zn > 57) {
            if($zn < 97 || $zn > 122) {
                if($zn != 32 && $zn != ord('-') && $zn != ord('!') && $zn != ord('?') && $zn != ord('&') && $zn != ord('+') && $zn != ord('.') & $zn != ord('_')) {
                    WriteLog("[TestNewPassword] zn = ".$zn." (".chr($zn).")");
                    $err = true; break;}}}}
    if($err) {
        $report = Lng('TestNewPasswordBadChars');
        return false;}
    return true;}
function TestIsNumberBiggerThanZero($caption,$value,&$report="") {
    $report = "";
    if(!is_numeric($value)) { $report = Lng('FormFieldMustBeNumber',Lng($caption)); return false; }
    if($value <= 0) { $report = Lng('SelectValueInFormField',Lng($caption)); return false; }
    return true;}
function TestIsNumberBiggerThanMinusOne($caption,$value,&$report="") {
    $report = "";
    if(!is_numeric($value)) { $report = Lng('FormFieldMustBeNumber',Lng($caption)); return false; }
    if($value <= -1) { $report = Lng('SelectValueInFormField',Lng($caption)); return false; }
    return true;}
function TestAcademicTitleType($caption,$value,&$report="") {
    $report = "";
    if(!is_numeric($value)) { $report = Lng('FormFieldMustBeNumber',Lng($caption)); return false; }
    if($value <= 0) { $report = Lng('SelectValueInFormField',Lng($caption)); return false; }
    return true;}
function Tab($table_name) {
    global $TABLE;
    if(IsSet($TABLE[$table_name]) && $TABLE[$table_name]['TABLE_FullName']) {
        return $TABLE[$table_name]['TABLE_FullName'];}
    AddError("Tabulka s názvem $table_name není definována!");
    return false;}
function Tab_Create($table_name,$table_full_name) {
    global $TABLE, $MTPS;
    $TABLE[$table_name] = array();
    $TABLE[$table_name]['TABLE_FullName'] = $MTPS->MySQL_Prefix.$table_full_name;
    $TABLE[$table_name]['TABLE_Name'] = $table_name;
    $TABLE[$table_name]['ID'] = array();
    $TABLE[$table_name]['ID']['type'] = "unsigned int";
    $TABLE[$table_name]['ID']['value'] = "";
    $TABLE[$table_name]['ID']['extra'] = "AUTO_INCREMENT";
    $TABLE[$table_name]['ID']['index'] = "";
    $TABLE[$table_name]['Created'] = array();
    $TABLE[$table_name]['Created']['type'] = "unsigned int";
    $TABLE[$table_name]['Created']['value'] = "0";
    $TABLE[$table_name]['Created']['extra'] = "";
    $TABLE[$table_name]['Created']['index'] = "INDEX";
    $TABLE[$table_name]['Changed'] = array();
    $TABLE[$table_name]['Changed']['type'] = "unsigned int";
    $TABLE[$table_name]['Changed']['value'] = "0";
    $TABLE[$table_name]['Changed']['extra'] = "";
    $TABLE[$table_name]['Changed']['index'] = "INDEX";
    $TABLE[$table_name]['Deleted'] = array();
    $TABLE[$table_name]['Deleted']['type'] = "unsigned int";
    $TABLE[$table_name]['Deleted']['value'] = "0";
    $TABLE[$table_name]['Deleted']['extra'] = "";
    $TABLE[$table_name]['Deleted']['index'] = "INDEX";}
function Tab_AddCol($table_name,$col_name,$col_type,$default_value,$index_type="") {
    global $TABLE;
    $TABLE[$table_name][$col_name] = array();
    $TABLE[$table_name][$col_name]['type'] = $col_type;
    $TABLE[$table_name][$col_name]['value'] = $default_value;
    $TABLE[$table_name][$col_name]['extra'] = "";
    $TABLE[$table_name][$col_name]['index'] = $index_type;}
$___mtps3file = $fileWEB."scripts/php/tables.php";
if(@file_exists($___mtps3file)) { include_once($___mtps3file); }
$___mtps3file = $fileWEB."templates/".$MTPS->DefaultLayout."/scripts/php/tables.php";
if(@file_exists($___mtps3file)) { include_once($___mtps3file); }
$tab = "Settings";
Tab_Create($tab,"settings");
Tab_AddCol($tab,"Name","VARCHAR(48)","","INDEX");
Tab_AddCol($tab,"UserID","unsigned int","0","INDEX");
Tab_AddCol($tab,"Num","int","0","INDEX");
Tab_AddCol($tab,"Data","text","","");
$tab = "Users";
Tab_Create($tab,"users");
if(Settings('EnableUsersLanguage')) {
    Tab_AddCol($tab,"Language","VARCHAR(3)","","INDEX");}
Tab_AddCol($tab,"Username","VARCHAR(128)","","INDEX");
if(Settings('EnableUniqueUrlPaths_Usernames')) {
    Tab_AddCol($tab,"UsernamePath","VARCHAR(128)","","INDEX");
    Tab_AddCol($tab,"UsernamePathLastChange","int","0","INDEX");}
Tab_AddCol($tab,"Password","text","","");
Tab_AddCol($tab,"Email","VARCHAR(128)","","INDEX");
Tab_AddCol($tab,"EmailAuthTime","int","0","");
if(Settings('EnableVirtualUsersAccounts')) {
    Tab_AddCol($tab,"Virtual","tinyint","0","");}
Tab_AddCol($tab,"AccountType","tinyint","0","INDEX");
Tab_AddCol($tab,"Deactivated","int","0","INDEX");
if(Settings('EnableUserLoginReminder',true)) {
    Tab_AddCol($tab,"LastReminderSent","int","0","INDEX");}
Tab_AddCol($tab,"FirstName","text","","FULLTEXT");
Tab_AddCol($tab,"MiddleName","text","","FULLTEXT");
Tab_AddCol($tab,"LastName","text","","FULLTEXT");
if(Settings('EnableUsersCompany')) {
    Tab_AddCol($tab,"Company","text","","FULLTEXT");}
if(Settings('EnableUsersCity')) {
    Tab_AddCol($tab,"City","text","","FULLTEXT");}
if(Settings('EnableAcademicTitles',true)) {
    Tab_AddCol($tab,"AcademicTitles","text","","");}
if(Settings('EnableUserInvitedBy',true)) {
    Tab_AddCol($tab,"InvitedBy","unsigned int","0","INDEX");}
if(Settings('EnablePoliticalParties',true)) {
    Tab_AddCol($tab,"PoliticalParty","unsigned int","0","INDEX");}
if(Settings('EnableEmployeesUserAccounts',true)) {
    Tab_AddCol($tab,"Telephone","text","","FULLTEXT");
    Tab_AddCol($tab,"MobilePhone","text","","FULLTEXT");
    if(Settings('EnableDepartments',true)) {
        Tab_AddCol($tab,"IsChiefOfDepartmentID","unsigned int","0","INDEX");}
    Tab_AddCol($tab,"Function","text","","FULLTEXT");
    Tab_AddCol($tab,"FunctionDescription","text","","FULLTEXT");
    if(Settings('EnableBuildingsAndLocations',true)) {
        Tab_AddCol($tab,"BuildingID","unsigned int","0","INDEX");
        Tab_AddCol($tab,"Level","text","","");
        Tab_AddCol($tab,"Doors","text","","");}}
if(Settings('CreateContactListFromUsers',true)) {
    Tab_AddCol($tab,"ShowInContacts","tinyint","0","INDEX");}
Tab_AddCol($tab,"LastLoginTime","int","0","INDEX");
Tab_AddCol($tab,"ConHash","VARCHAR(16)","","");
if(Settings('EnableNews') && Settings('EnableNewsGroups')) {
    Tab_AddCol($tab,"DefaultNewsGroupID","unsigned int","0","");}
if(ModuleEnabled('pim')) {
    Tab_AddCol($tab,"OrganizerID","unsigned int","0","INDEX");
    Tab_AddCol($tab,"OrganizersLastRecalc","int","0","");
    Tab_AddCol($tab,"LastPimUpdateTime","int","0","INDEX");
    Tab_AddCol($tab,"UsersOrganizersLastRecalc","int","0","");
    Tab_AddCol($tab,"UsersOrganizers","text","","");
    Tab_AddCol($tab,"InContactsGroups","text","","");
    Tab_AddCol($tab,"InContactsLists","text","","");}
if(Settings('EnableNewsletter')) {
    Tab_AddCol($tab,"SendNewsletter","tinyint",$MTPS->Settings['NewsletterDelaultValue'],"INDEX");}
if($MTPS->UserCanBuyLicense) {
    Tab_AddCol($tab,"LicenseType","tinyint","0","");
    Tab_AddCol($tab,"LicenseExpirationDate","date","0000-00-00","INDEX");
    Tab_AddCol($tab,"LicenseDiscount","tinyint","0","");
    if(Settings('EnableLicenseBuyReminder',true)) {
        Tab_AddCol($tab,"LicenseBuyLastReminder","int","0","");}}
if(Settings('UserCanChangeLayout')) {
    Tab_AddCol($tab,"Layout","VARCHAR(16)","","INDEX");}
if(Settings('EnableAPI')) {
    Tab_AddCol($tab,"AppID","tinyint","0","INDEX");
    Tab_AddCol($tab,"AppVersion","smallint","0","INDEX");
    Tab_AddCol($tab,"AppLastLogin","int","0","");}
if(Settings('EnableUsersProfilePicture')) {
    Tab_AddCol($tab,"ProfilePicture","int","0","");}
if(Settings('EnableSortPosInUsersTable')) {
    Tab_AddCol($tab,"SortPos","smallint","0","INDEX");}
if(Settings('EnableUsersSettings')) {
    Tab_AddCol($tab,"Settings","text","","");}
if(Settings('EnablePages',true)) {
    $tab = "Pages";
    Tab_Create($tab,"pages");
    Tab_AddCol($tab,"ParentID","unsigned int","0","INDEX");
    Tab_AddCol($tab,"Type","tinyint","0","INDEX");
    Tab_AddCol($tab,"Name","VARCHAR(128)","","INDEX");
    Tab_AddCol($tab,"Title","text","","FULLTEXT");
    Tab_AddCol($tab,"ShowTitle","tinyint","1","");
    Tab_AddCol($tab,"ShowSubpages","tinyint","1","INDEX");
    Tab_AddCol($tab,"ShowAttachments","tinyint","1","INDEX");
    Tab_AddCol($tab,"RedirectTo","unsigned int","0");
    Tab_AddCol($tab,"SortPos","smallint","0","INDEX");
    Tab_AddCol($tab,"CreatedByUserID","unsigned int","0","INDEX");
    Tab_AddCol($tab,"Settings","text","","");
    if(Settings('EnablePagesTiles',true)) {
        Tab_AddCol($tab,"PageTile","int","0","");
        Tab_AddCol($tab,"InfopageImage","int","0","");}
    $tab = "PagesContents";
    Tab_Create($tab,"pages_contents");
    Tab_AddCol($tab,"PageID","unsigned int","0","INDEX");
    Tab_AddCol($tab,"Language","VARCHAR(3)","","INDEX");
    Tab_AddCol($tab,"Published","int","0","INDEX");
    Tab_AddCol($tab,"Content","text","","");
    Tab_AddCol($tab,"PlainContent","text","","FULLTEXT");
    Tab_AddCol($tab,"CreatedByUserID","unsigned int","0","");
    $tab = "PagesURLs";
    Tab_Create($tab,"pages_urls");
    Tab_AddCol($tab,"PageID","unsigned int","0","INDEX");
    Tab_AddCol($tab,"Language","VARCHAR(3)","","INDEX");
    Tab_AddCol($tab,"URL","VARCHAR(1024)","","INDEX");
    $tab = "PagesImages";
    Tab_Create($tab,"pages_images");
    Tab_AddCol($tab,"PageID","unsigned int","0","INDEX");
    Tab_AddCol($tab,"Extension","VARCHAR(5)","","INDEX");
    Tab_AddCol($tab,"CreatedByUserID","unsigned int","0","INDEX");
    if(Settings('EnablePagesAttachments',true)) {
        $tab = "PagesAttachments";
        Tab_Create($tab,"pages_attachments");
        Tab_AddCol($tab,"Type","tinyint","0","INDEX");
        Tab_AddCol($tab,"ParentID","unsigned int","0","INDEX");
        Tab_AddCol($tab,"PageID","unsigned int","0","INDEX");
        Tab_AddCol($tab,"Title","text","","FULLTEXT");
        Tab_AddCol($tab,"Filename","text","","");
        Tab_AddCol($tab,"Extension","VARCHAR(5)","","INDEX");
        Tab_AddCol($tab,"Size","unsigned int","0","");
        Tab_AddCol($tab,"Published","tinyint","0","INDEX");
        Tab_AddCol($tab,"SortPos","smallint","0","INDEX");
        Tab_AddCol($tab,"CreatedByUserID","unsigned int","0","INDEX");}
    if(Settings('EnableDocumentsToDownloadByDepartments',true)) {
        $tab = "DocumentsToDownloadByDepartments";
        Tab_Create($tab,"download_documents_dept");
        Tab_AddCol($tab,"DepartmentID","unsigned int","0","INDEX");
        Tab_AddCol($tab,"Language","VARCHAR(3)","","INDEX");
        Tab_AddCol($tab,"Type","tinyint","0","INDEX");
        Tab_AddCol($tab,"Title","text","","FULLTEXT");
        Tab_AddCol($tab,"Filename","text","","");
        Tab_AddCol($tab,"Extension","VARCHAR(5)","","INDEX");
        Tab_AddCol($tab,"Size","unsigned int","0","");
        Tab_AddCol($tab,"Published","tinyint","0","INDEX");
        Tab_AddCol($tab,"SortPos","smallint","0","INDEX");
        Tab_AddCol($tab,"CreatedByUserID","unsigned int","0","INDEX");}}
if(Settings('EnableLocalTV',true)) {
    $tab = "LocalTV";
    Tab_Create($tab,"local_tv");
    Tab_AddCol($tab,"Language","VARCHAR(3)","","INDEX");
    Tab_AddCol($tab,"URL","text","","");
    Tab_AddCol($tab,"Title","text","","FULLTEXT");
    Tab_AddCol($tab,"Placement","text","","INDEX");
    Tab_AddCol($tab,"BroadcastDate","DATE","0000-00-00","INDEX");
    Tab_AddCol($tab,"ImageURL","text","","");
    Tab_AddCol($tab,"CreatedByUserID","unsigned int","0","INDEX");}
if(Settings('EnableSportEventsDonations',true)) {
    $tab = "SportDonations_Categories";
    Tab_Create($tab,"sport_donations_categories");
    Tab_AddCol($tab,"ParentID","unsigned int","0","INDEX");
    Tab_AddCol($tab,"SortPos","smallint","0","INDEX");
    Tab_AddCol($tab,"Language","VARCHAR(3)","","INDEX");
    Tab_AddCol($tab,"Title","text","","FULLTEXT");
    Tab_AddCol($tab,"Name","VARCHAR(128)","","INDEX");
    Tab_AddCol($tab,"CreatedByUserID","unsigned int","0","INDEX");
    $tab = "SportDonations_Items";
    Tab_Create($tab,"sport_donations_items");
    Tab_AddCol($tab,"CategoryID","unsigned int","0","INDEX");
    Tab_AddCol($tab,"Promoter","text","","FULLTEXT");
    Tab_AddCol($tab,"Event","text","","FULLTEXT");
    Tab_AddCol($tab,"Amount","int","0","");
    Tab_AddCol($tab,"Text","text","","FULLTEXT");
    Tab_AddCol($tab,"Name","VARCHAR(128)","","INDEX");
    Tab_AddCol($tab,"CreatedByUserID","unsigned int","0","INDEX");
    $tab = "SportDonations_Images";
    Tab_Create($tab,"sport_donations_images");
    Tab_AddCol($tab,"ItemID","unsigned int","0","INDEX");
    Tab_AddCol($tab,"CreatedByUserID","unsigned int","0","INDEX");}
if(Settings('EnableCalendar',true)) {
    $tab = "Calendar";
    Tab_Create($tab,"calendar");
    Tab_AddCol($tab,"Language","VARCHAR(3)","","INDEX");
    Tab_AddCol($tab,"Title","text","","FULLTEXT");
    Tab_AddCol($tab,"Text","text","","");
    Tab_AddCol($tab,"PlainText","text","","FULLTEXT");
    Tab_AddCol($tab,"Place","text","","FULLTEXT");
    Tab_AddCol($tab,"CreatedDate","DATE","0000-00-00","INDEX");
    Tab_AddCol($tab,"Date","DATE","0000-00-00","INDEX");
    Tab_AddCol($tab,"Time","TIME","99:00:00","INDEX");
    Tab_AddCol($tab,"IconFilename","text","","");
    Tab_AddCol($tab,"IconWidth","smallint","0","");
    Tab_AddCol($tab,"IconHeight","smallint","0","");
    Tab_AddCol($tab,"CreatedByUserID","unsigned int","0","INDEX");
    $tab = "CalendarImages";
    Tab_Create($tab,"calendar_images");
    Tab_AddCol($tab,"PageID","unsigned int","0","INDEX");
    Tab_AddCol($tab,"Extension","VARCHAR(5)","","INDEX");
    Tab_AddCol($tab,"CreatedByUserID","unsigned int","0","INDEX");
    if(Settings('EnableCalendarAttachments',true)) {
        $tab = "CalendarAttachments";
        Tab_Create($tab,"calendar_attachments");
        Tab_AddCol($tab,"Type","tinyint","0","INDEX");
        Tab_AddCol($tab,"ParentID","unsigned int","0","INDEX");
        Tab_AddCol($tab,"CalendarItemID","unsigned int","0","INDEX");
        Tab_AddCol($tab,"Title","text","","FULLTEXT");
        Tab_AddCol($tab,"Filename","text","","");
        Tab_AddCol($tab,"Extension","VARCHAR(5)","","INDEX");
        Tab_AddCol($tab,"Size","unsigned int","0","");
        Tab_AddCol($tab,"Published","tinyint","0","INDEX");
        Tab_AddCol($tab,"SortPos","smallint","0","INDEX");
        Tab_AddCol($tab,"CreatedByUserID","unsigned int","0","INDEX");}}
if(Settings('EnableGallery',true)) {
    $tab = "GalleryImages";
    Tab_Create($tab,"gallery_images");
    Tab_AddCol($tab,"AlbumID","unsigned int","0","INDEX");
    Tab_AddCol($tab,"Title","text","","FULLTEXT");
    Tab_AddCol($tab,"Text","text","","FULLTEXT");
    Tab_AddCol($tab,"Path","VARCHAR(128)","","");
    Tab_AddCol($tab,"Extension","VARCHAR(5)","","INDEX");
    Tab_AddCol($tab,"ImageWidth","smallint","0","");
    Tab_AddCol($tab,"ImageHeight","smallint","0","");
    Tab_AddCol($tab,"Published","int","0","INDEX");
    Tab_AddCol($tab,"SortPos","smallint","0","INDEX");
    Tab_AddCol($tab,"CreatedByUserID","unsigned int","0","INDEX");
    $tab = "GalleryAlbums";
    Tab_Create($tab,"gallery_albums");
    Tab_AddCol($tab,"Title","text","","FULLTEXT");
    Tab_AddCol($tab,"Visibility","tinyint","0","INDEX");
    Tab_AddCol($tab,"Date","DATE","0000-00-00","INDEX");
    Tab_AddCol($tab,"CreatedByUserID","unsigned int","0","INDEX");}
if(Settings('EnableNews',true)) {
    $tab = "News";
    Tab_Create($tab,"news");
    Tab_AddCol($tab,"Language","VARCHAR(3)","","INDEX");
    Tab_AddCol($tab,"CreatedDate","DATE","0000-00-00","INDEX");
    Tab_AddCol($tab,"PublishedDate","DATE","0000-00-00","INDEX");
    Tab_AddCol($tab,"PublishedTime","TIME","99:00:00","INDEX");
    Tab_AddCol($tab,"CategoryID","unsigned int","0","INDEX");
    Tab_AddCol($tab,"Title","text","","FULLTEXT");
    Tab_AddCol($tab,"Text","text","","");
    Tab_AddCol($tab,"PlainText","text","","FULLTEXT");
    Tab_AddCol($tab,"IconFilename","text","","");
    Tab_AddCol($tab,"IconWidth","smallint","0","");
    Tab_AddCol($tab,"IconHeight","smallint","0","");
    Tab_AddCol($tab,"CreatedByUserID","unsigned int","0","INDEX");
    Tab_AddCol($tab,"Pin","int","0","INDEX");
    if(Settings('EnableNewsGroups')) {
        Tab_AddCol($tab,"NewsGroupID","unsigned int","0","INDEX");}
    if(Settings('EnableEventsFromNews')) {
        Tab_AddCol($tab,"IsEvent","tinyint","0","INDEX");
        Tab_AddCol($tab,"DateEnd","date","0000-00-00","INDEX");
        Tab_AddCol($tab,"TimeEnd","time","99:00:00","INDEX");}
    $tab = "NewsImages";
    Tab_Create($tab,"news_images");
    Tab_AddCol($tab,"NewsID","unsigned int","0","INDEX");
    Tab_AddCol($tab,"Extension","VARCHAR(5)","","INDEX");
    Tab_AddCol($tab,"CreatedByUserID","unsigned int","0","INDEX");
    $tab = "NewsCategories";
    Tab_Create($tab,"news_categories");
    Tab_AddCol($tab,"Language","VARCHAR(3)","","INDEX");
    Tab_AddCol($tab,"Title","text","","FULLTEXT");
    Tab_AddCol($tab,"CreatedByUserID","unsigned int","0","INDEX");
    $tab = "NewsStats";
    Tab_Create($tab,"news_stats");
    Tab_AddCol($tab,"NewsID","unsigned int","0","INDEX");
    Tab_AddCol($tab,"Date","date","0000-00-00","INDEX");
    Tab_AddCol($tab,"Hour","tinyint","-1","INDEX");
    Tab_AddCol($tab,"Minute","tinyint","-1","INDEX");
    if($MTPS->SaveWebAccess) {
        Tab_AddCol($tab,"WebAccessID","int","0","INDEX");}
    Tab_AddCol($tab,"UserID","unsigned int","0","INDEX");
    $tab = "NewsAttachments";
    Tab_Create($tab,"news_attachments");
    Tab_AddCol($tab,"NewsID","unsigned int","0","INDEX");
    Tab_AddCol($tab,"Title","text","","FULLTEXT");
    Tab_AddCol($tab,"Filename","text","","");
    Tab_AddCol($tab,"Extension","VARCHAR(5)","","INDEX");
    Tab_AddCol($tab,"Size","unsigned int","0","");
    Tab_AddCol($tab,"Published","tinyint","0","INDEX");
    Tab_AddCol($tab,"SortPos","smallint","0","INDEX");
    Tab_AddCol($tab,"CreatedByUserID","unsigned int","0","INDEX");}
if(Settings('EnableEUD',true)) {
    $tab = "EUD";
    Tab_Create($tab,"eud");
    Tab_AddCol($tab,"StringID","VARCHAR(20)","","INDEX");
    Tab_AddCol($tab,"Category","VARCHAR(32)","","INDEX");
    Tab_AddCol($tab,"Title","text","","FULLTEXT");
    Tab_AddCol($tab,"Text","text","","");
    Tab_AddCol($tab,"PlainText","text","","FULLTEXT");
    Tab_AddCol($tab,"Source","VARCHAR(64)","","INDEX");
    Tab_AddCol($tab,"NegotiatingID","VARCHAR(20)","","INDEX");
    Tab_AddCol($tab,"DateFrom","date","0000-00-00","INDEX");
    Tab_AddCol($tab,"DateTo","date","0000-00-00","INDEX");
    Tab_AddCol($tab,"Note","text","","");
    Tab_AddCol($tab,"Year","smallint","0","INDEX");
    Tab_AddCol($tab,"Month","tinyint","0","INDEX");
    Tab_AddCol($tab,"Files","tinyint","0","INDEX");
    Tab_AddCol($tab,"CreatedByUserID","unsigned int","0","INDEX");
    $tab = "EUDFiles";
    Tab_Create($tab,"eud_files");
    Tab_AddCol($tab,"ItemID","unsigned int","0","INDEX");
    Tab_AddCol($tab,"File","text","","");
    Tab_AddCol($tab,"Note","text","","");
    Tab_AddCol($tab,"Path","text","","");
    Tab_AddCol($tab,"Size","unsigned int","0","INDEX");}
if($MTPS->UserCanBuyLicense) {
    $tab = "ShopOrderIDs";
    Tab_Create($tab,"shop_orders_ids_".sprintf("%02d%02d",Date("y"),12));
    Tab_AddCol($tab,"OrderID","VARCHAR(10)","","INDEX");}
if(ModuleEnabled('pim')) {
    $tab = "PIM_Print";
    Tab_Create($tab,"pim_print");
    Tab_AddCol($tab,"UserID","unsigned int","0","INDEX");
    Tab_AddCol($tab,"File","text","","");
    Tab_AddCol($tab,"Title","text","","");
    $tab = "PIM_Organizers";
    Tab_Create($tab,"pim_organizers");
    Tab_AddCol($tab,"UserID","unsigned int","0","INDEX");
    Tab_AddCol($tab,"Title","text","","");
    Tab_AddCol($tab,"Note","text","","");
    Tab_AddCol($tab,"Name","VARCHAR(128)","","INDEX");
    Tab_AddCol($tab,"NameLastChangeTime","int","0","");
    Tab_AddCol($tab,"Type","tinyint","0","INDEX");
    Tab_AddCol($tab,"Visibility","tinyint","0","INDEX");
    Tab_AddCol($tab,"SubscribersCount","unsigned int","0","INDEX");
    Tab_AddCol($tab,"CalendarIcon","int","0","");
    Tab_AddCol($tab,"CalendarIconName","VARCHAR(128)","","");
    $tab = "PIM_UsersOrganizers";
    Tab_Create($tab,"pim_users_organizers");
    Tab_AddCol($tab,"UserID","unsigned int","0","INDEX");
    Tab_AddCol($tab,"OrganizerID","unsigned int","0","INDEX");
    Tab_AddCol($tab,"Origin","tinyint","0","INDEX");
    Tab_AddCol($tab,"Subscribe","tinyint","1","INDEX");
    $tab = "PIM_Records";
    Tab_Create($tab,"pim_records");
    Tab_AddCol($tab,"OrganizerID","unsigned int","0","INDEX");
    Tab_AddCol($tab,"CreatedByUserID","unsigned int","0","INDEX");
    Tab_AddCol($tab,"ParentID","unsigned int","0","INDEX");
    Tab_AddCol($tab,"HasChildren","tinyint","-1","INDEX");
    Tab_AddCol($tab,"Type","tinyint","0","INDEX");
    Tab_AddCol($tab,"EventType","tinyint","0","INDEX");
    Tab_AddCol($tab,"Text","TEXT","","");
    Tab_AddCol($tab,"PlainText","text","","FULLTEXT");
    Tab_AddCol($tab,"Importance","tinyint","0","INDEX");
    Tab_AddCol($tab,"Finished","tinyint","-1","INDEX");
    Tab_AddCol($tab,"FinishedTime","int","0","INDEX");
    Tab_AddCol($tab,"HasBegin","tinyint","0","INDEX");
    Tab_AddCol($tab,"DateBegin","date","0000-00-00","INDEX");
    Tab_AddCol($tab,"TimeBegin","time","99:00:00","INDEX");
    Tab_AddCol($tab,"HasEnd","tinyint","0","INDEX");
    Tab_AddCol($tab,"DateEnd","date","0000-00-00","INDEX");
    Tab_AddCol($tab,"TimeEnd","time","99:00:00","INDEX");
    Tab_AddCol($tab,"Reschedule","tinyint","0","INDEX");
    Tab_AddCol($tab,"Note","TEXT","","");
    Tab_AddCol($tab,"PlainNote","text","","FULLTEXT");
    Tab_AddCol($tab,"RepeatInterval","tinyint","0","INDEX");
    Tab_AddCol($tab,"Visibility","tinyint","0","INDEX");
    Tab_AddCol($tab,"PromoterID","unsigned int","0","INDEX");
    Tab_AddCol($tab,"Place","text","","");
    Tab_AddCol($tab,"PlaceID","unsigned int","0","INDEX");
    Tab_AddCol($tab,"MainPicture","int","0","");
    Tab_AddCol($tab,"Settings","text","","");
    $tab = "PIM_Sharing";
    Tab_Create($tab,"pim_sharing");
    Tab_AddCol($tab,"OrganizerID","unsigned int","0","INDEX");
    Tab_AddCol($tab,"RecordID","unsigned int","0","INDEX");
    Tab_AddCol($tab,"Type","tinyint","0","");
    Tab_AddCol($tab,"ObjectID","unsigned int","0","INDEX");
    Tab_AddCol($tab,"Rights","tinyint","0","");
    Tab_AddCol($tab,"RecordType","tinyint","-1","INDEX");
    Tab_AddCol($tab,"HasBegin","tinyint","-1","INDEX");
    Tab_AddCol($tab,"DateBegin","date","0000-00-00","INDEX");
    Tab_AddCol($tab,"DateEnd","date","0000-00-00","INDEX");
    $tab = "PIM_Tags";
    Tab_Create($tab,"pim_tags");
    Tab_AddCol($tab,"OrganizerID","unsigned int","0","INDEX");
    Tab_AddCol($tab,"Title","TEXT","","FULLTEXT");
    $tab = "PIM_TagsAssign";
    Tab_Create($tab,"pim_tags_assign");
    Tab_AddCol($tab,"OrganizerID","unsigned int","0","INDEX");
    Tab_AddCol($tab,"RecordID","unsigned int","0","INDEX");
    Tab_AddCol($tab,"TagID","unsigned int","0","INDEX");
    $tab = "PIM_Alerts";
    Tab_Create($tab,"pim_alerts");
    Tab_AddCol($tab,"UserID","unsigned int","0","INDEX");
    Tab_AddCol($tab,"OrganizerID","unsigned int","0","INDEX");
    Tab_AddCol($tab,"RecordID","unsigned int","0","INDEX");
    Tab_AddCol($tab,"Type","tinyint","0","INDEX");
    Tab_AddCol($tab,"DaysBefore","tinyint","0","");
    Tab_AddCol($tab,"HoursBefore","tinyint","0","");
    Tab_AddCol($tab,"MinutesBefore","tinyint","0","");
    Tab_AddCol($tab,"AlertTimestamp","int","0","INDEX");
    Tab_AddCol($tab,"Settings","TEXT","","");
    $tab = "PIM_ContactsGroups";
    Tab_Create($tab,"pim_contacts_groups");
    Tab_AddCol($tab,"UserID","unsigned int","0","INDEX");
    Tab_AddCol($tab,"Title","VARCHAR(64)","","INDEX");
    $tab = "PIM_ContactsGroupsAssign";
    Tab_Create($tab,"pim_contacts_groups_assign");
    Tab_AddCol($tab,"UserID","unsigned int","0","INDEX");
    Tab_AddCol($tab,"ContactID","unsigned int","0","INDEX");
    Tab_AddCol($tab,"ContactUserID","unsigned int","0","INDEX");
    Tab_AddCol($tab,"ContactsGroupID","unsigned int","0","INDEX");
    $tab = "PIM_Contacts";
    Tab_Create($tab,"pim_contacts");
    Tab_AddCol($tab,"UserID","unsigned int","0","INDEX");
    Tab_AddCol($tab,"ContactUserID","unsigned int","0","INDEX");
    if(Settings('EnableUniqueUrlPaths_Usernames')) {
        Tab_AddCol($tab,"UsernamePath","VARCHAR(128)","","INDEX");}
    Tab_AddCol($tab,"FirstName","text","","FULLTEXT");
    Tab_AddCol($tab,"MiddleName","text","","FULLTEXT");
    Tab_AddCol($tab,"LastName","text","","FULLTEXT");
    if(Settings('EnableUsersCompany')) {
        Tab_AddCol($tab,"Company","text","","FULLTEXT");}
    if(Settings('EnableUsersCity')) {
        Tab_AddCol($tab,"City","text","","FULLTEXT");}
    if(Settings('EnableAcademicTitles',true)) {
        Tab_AddCol($tab,"AcademicTitles","text","","");}
    if(Settings('EnableUsersProfilePicture')) {
        Tab_AddCol($tab,"ProfilePicture","int","0","");}
    if(Settings('EnableContactsDisplayNameAs')) {
        Tab_AddCol($tab,"DisplayAs","text","","FULLTEXT");}
    $tab = "PIM_ContactsRequests";
    Tab_Create($tab,"pim_contacts_requests");
    Tab_AddCol($tab,"UserID","unsigned int","0","INDEX");
    Tab_AddCol($tab,"ContactUserID","unsigned int","0","INDEX");
    Tab_AddCol($tab,"RequestIP","VARCHAR(15)","");
    Tab_AddCol($tab,"AcceptanceIP","VARCHAR(15)","");
    Tab_AddCol($tab,"AcceptanceType","tinyint","0","INDEX");
    Tab_AddCol($tab,"AcceptanceTimestamp","int","0","INDEX");
    Tab_AddCol($tab,"EmailID","unsigned int","0","INDEX");
    $tab = "PIM_EventTypes";
    Tab_Create($tab,"pim_event_types");
    Tab_AddCol($tab,"CreatedByUserID","unsigned int","0","INDEX");
    Tab_AddCol($tab,"TitleLngString","TEXT","","");
    Tab_AddCol($tab,"ShowBeforeText","tinyint","0","INDEX");
    $tab = "PIM_Promoters";
    Tab_Create($tab,"pim_promoters");
    Tab_AddCol($tab,"CreatedByUserID","unsigned int","0","INDEX");
    Tab_AddCol($tab,"Title","TEXT","","FULLTEXT");
    $tab = "PIM_PromotersAssign";
    Tab_Create($tab,"pim_promoters_assign");
    Tab_AddCol($tab,"UserID","unsigned int","0","INDEX");
    Tab_AddCol($tab,"PromoterID","unsigned int","0","INDEX");}
if($MTPS->UserCanBuyLicense) {
    $tab = "LicenseOrders";
    Tab_Create($tab,"license_orders");
    Tab_AddCol($tab,"PaymentDate","int","0","INDEX");
    Tab_AddCol($tab,"VS","VARCHAR(10)","","INDEX");
    Tab_AddCol($tab,"LicenseVariant","tinyint","0","INDEX");
    Tab_AddCol($tab,"Price","int","0","");
    Tab_AddCol($tab,"UserID","unsigned int","0","INDEX");
    Tab_AddCol($tab,"Username","VARCHAR(128)","","INDEX");
    Tab_AddCol($tab,"Email","VARCHAR(128)","","INDEX");
    Tab_AddCol($tab,"FullName","TEXT","","");
    Tab_AddCol($tab,"Address","TEXT","","");
    Tab_AddCol($tab,"City","TEXT","","");
    Tab_AddCol($tab,"ZIP","TEXT","","");
    Tab_AddCol($tab,"Country","TEXT","","");
    Tab_AddCol($tab,"IC","TEXT","","");
    Tab_AddCol($tab,"DIC","TEXT","","");
    Tab_AddCol($tab,"PhoneNumber","TEXT","","");
    Tab_AddCol($tab,"LastReminderSent","int","0","INDEX");}
if(Settings('EnableDepartments',true)) {
    $tab = "Departments";
    Tab_Create($tab,"departments");
    Tab_AddCol($tab,"SortPos","smallint","0","INDEX");
    Tab_AddCol($tab,"ParentID","unsigned int","0","INDEX");
    Tab_AddCol($tab,"DeptNo","smallint","0","INDEX");
    Tab_AddCol($tab,"Title","text","","FULLTEXT");
    Tab_AddCol($tab,"Shortcut","VARCHAR(12)","","INDEX");
    Tab_AddCol($tab,"Description","text","","FULLTEXT");
    Tab_AddCol($tab,"ChiefUserID","unsigned int","0","INDEX");
    Tab_AddCol($tab,"ShowInContacts","tinyint","0","INDEX");
    Tab_AddCol($tab,"FontColor","VARCHAR(16)","","");
    Tab_AddCol($tab,"BackgroundColor","VARCHAR(16)","","");
    $tab = "UsersDepartmentsAssign";
    Tab_Create($tab,"users_departments_assign");
    Tab_AddCol($tab,"UserID","unsigned int","0","INDEX");
    Tab_AddCol($tab,"DepartmentID","unsigned int","0","INDEX");}
if(Settings('EnableBuildingsAndLocations',true)) {
    $tab = "Buildings";
    Tab_Create($tab,"buildings");
    Tab_AddCol($tab,"Title","text","","");}
if(Settings('EnablePoliticalParties',true)) {
    $tab = "PoliticalParties";
    Tab_Create($tab,"political_parties");
    Tab_AddCol($tab,"Shortcut","TEXT","","");
    Tab_AddCol($tab,"Title","text","","");}
if(Settings('EnableAcademicTitles',true)) {
    $tab = "AcademicTitles";
    Tab_Create($tab,"academic_titles");
    Tab_AddCol($tab,"Type","tinyint","0","INDEX");
    Tab_AddCol($tab,"Shortcut","VARCHAR(12)","","INDEX");
    Tab_AddCol($tab,"FullTitle","text","","");
    Tab_AddCol($tab,"ShowInList","tinyint","0","INDEX");}
if(Settings('EnableAgendas',true)) {
    $tab = "Agendas";
    Tab_Create($tab,"agendas");
    Tab_AddCol($tab,"Title","text","","FULLTEXT");
    Tab_AddCol($tab,"Note","text","","FULLTEXT");
    $tab = "UsersAgendasAssign";
    Tab_Create($tab,"users_agendas_assign");
    Tab_AddCol($tab,"UserID","unsigned int","0","INDEX");
    Tab_AddCol($tab,"AgendaID","unsigned int","0","INDEX");}
if(Settings('EnableUsersRights')) {
    $tab = "UsersRights";
    Tab_Create($tab,"users_rights");
    Tab_AddCol($tab,"Name","VARCHAR(32)","","INDEX");
    Tab_AddCol($tab,"AccountType","tinyint","1","INDEX");
    Tab_AddCol($tab,"TitleLnID","unsigned int","0","INDEX");
    Tab_AddCol($tab,"NoteLnID","unsigned int","0","INDEX");
    if(Settings('EnableUsersRights',true)) {
        Tab_AddCol($tab,"Title","text","","FULLTEXT");
        Tab_AddCol($tab,"Note","text","","");}
    $tab = "UsersRightsAssign";
    Tab_Create($tab,"users_rights_assign");
    Tab_AddCol($tab,"UserID","unsigned int","0","INDEX");
    Tab_AddCol($tab,"Name","VARCHAR(32)","","INDEX");
    Tab_AddCol($tab,"Rights","VARCHAR(8)","","");
    Tab_AddCol($tab,"UsersRightID","unsigned int","0","INDEX");}
$tab = "UsersSessions";
Tab_Create($tab,"users_sessions");
Tab_AddCol($tab,"UserID","unsigned int","0","INDEX");
Tab_AddCol($tab,"Hash","VARCHAR(16)","","INDEX");
$tab = "UsersOneTimeLogins";
Tab_Create($tab,"users_one_time_logins");
Tab_AddCol($tab,"UserID","unsigned int","0","INDEX");
Tab_AddCol($tab,"Username","VARCHAR(128)","","");
Tab_AddCol($tab,"Hash","VARCHAR(32)","","INDEX");
$tab = "EmailAuths";
Tab_Create($tab,"users_email_auths");
Tab_AddCol($tab,"Username","VARCHAR(128)","","INDEX");
Tab_AddCol($tab,"EmailPos","tinyint","0","");
Tab_AddCol($tab,"Email","VARCHAR(128)","","INDEX");
Tab_AddCol($tab,"Hash","VARCHAR(16)","","INDEX");
$tab = "NewPassReqs";
Tab_Create($tab,"users_new_pass_reqs");
Tab_AddCol($tab,"UserID","unsigned int","0","INDEX");
Tab_AddCol($tab,"Username","VARCHAR(128)","","INDEX");
Tab_AddCol($tab,"Email","VARCHAR(128)","","INDEX");
Tab_AddCol($tab,"Hash","VARCHAR(16)","","INDEX");
Tab_AddCol($tab,"IP","VARCHAR(15)","");
$tab = "StatsPages";
Tab_Create($tab,"stats_pages");
Tab_AddCol($tab,"HttpResponseCode","smallint","0","INDEX");
Tab_AddCol($tab,"IP","VARCHAR(15)","");
Tab_AddCol($tab,"Date","date","0000-00-00","INDEX");
Tab_AddCol($tab,"Hour","tinyint","-1","INDEX");
Tab_AddCol($tab,"Minute","tinyint","-1","INDEX");
Tab_AddCol($tab,"Protocol","tinyint","0");
Tab_AddCol($tab,"Host","VARCHAR(64)","");
Tab_AddCol($tab,"Path","VARCHAR(256)","","INDEX");
Tab_AddCol($tab,"Get","VARCHAR(256)","","");
Tab_AddCol($tab,"Layout","tinyint","0","INDEX");
Tab_AddCol($tab,"BrowserName","VARCHAR(32)","","INDEX");
Tab_AddCol($tab,"BrowserVersion","smallint","0","INDEX");
Tab_AddCol($tab,"Language","VARCHAR(2)","","INDEX");
Tab_AddCol($tab,"UserAgent","VARCHAR(256)","","");
Tab_AddCol($tab,"Referer","text","","");
if($MTPS->SaveWebAccess) {
    Tab_AddCol($tab,"WebAccessID","int","0","INDEX");}
Tab_AddCol($tab,"UserID","unsigned int","0","INDEX");
Tab_AddCol($tab,"PageID","unsigned int","0","INDEX");
$tab = "Emails";
Tab_Create($tab,"emails");
Tab_AddCol($tab,"Priority","tinyint","0","INDEX");
Tab_AddCol($tab,"RecipientEmail","VARCHAR(128)","","INDEX");
Tab_AddCol($tab,"RecipientName","VARCHAR(64)","","");
Tab_AddCol($tab,"Subject","VARCHAR(128)","","");
Tab_AddCol($tab,"ContentHTML","text","","");
Tab_AddCol($tab,"Attachments","text","","");
Tab_AddCol($tab,"FromSMTP","smallint","0","");
Tab_AddCol($tab,"ReplyToEmail","text","","");
Tab_AddCol($tab,"ReplyToName","text","","");
Tab_AddCol($tab,"SentResult","tinyint","0","INDEX");
Tab_AddCol($tab,"SentTime","int","0","INDEX");
Tab_AddCol($tab,"Note","text","","");
$tab = "SMTP";
Tab_Create($tab,"emails_smtp");
Tab_AddCol($tab,"FromEmail","VARCHAR(128)","","");
Tab_AddCol($tab,"FromName","VARCHAR(64)","","");
Tab_AddCol($tab,"Host","VARCHAR(64)","","");
Tab_AddCol($tab,"Port","smallint","25","");
Tab_AddCol($tab,"Username","VARCHAR(128)","","");
Tab_AddCol($tab,"Password","VARCHAR(64)","","");
$tab = "WebAccess";
Tab_Create($tab,"web_access");
Tab_AddCol($tab,"Count","int","0","");
Tab_AddCol($tab,"Hash","VARCHAR(8)","","INDEX");
$tab = "Sessions";
Tab_Create($tab,"sessions");
Tab_AddCol($tab,"WebAccessID","unsigned int","0","INDEX");
Tab_AddCol($tab,"Name","text","","");
Tab_AddCol($tab,"Value","text","","");
if(Settings('EnableIntranetModuleRMZM',true)) {
    $tab = "ZMRMMeetings";
    Tab_Create($tab,"zmrm_meetings");
    Tab_AddCol($tab,"Type","tinyint","0","INDEX");
    Tab_AddCol($tab,"MeetingNo","smallint","0","INDEX");
    Tab_AddCol($tab,"Date","date","0000-00-00","INDEX");
    Tab_AddCol($tab,"Running","unsigned int","0","INDEX");
    Tab_AddCol($tab,"RunningDocumentID","unsigned int","0","");
    Tab_AddCol($tab,"RunningItemID","unsigned int","0","");
    Tab_AddCol($tab,"Finished","unsigned int","0","INDEX");
    Tab_AddCol($tab,"CreatedByUserID","unsigned int","0","INDEX");
    $tab = "ZMRMDocuments";
    Tab_Create($tab,"zmrm_documents");
    Tab_AddCol($tab,"MeetingID","unsigned int","0","INDEX");
    Tab_AddCol($tab,"MeetingSection","smallint","0","INDEX");
    Tab_AddCol($tab,"DocumentNo","smallint","0","INDEX");
    Tab_AddCol($tab,"Title","text","","FULLTEXT");
    Tab_AddCol($tab,"Reason","longtext","","");
    Tab_AddCol($tab,"Text","text","","");
    Tab_AddCol($tab,"Running","unsigned int","0","INDEX");
    Tab_AddCol($tab,"Finished","unsigned int","0","INDEX");
    Tab_AddCol($tab,"CreatedByUserID","unsigned int","0","INDEX");
    $tab = "ZMRMItems";
    Tab_Create($tab,"zmrm_items");
    Tab_AddCol($tab,"MeetingID","unsigned int","0","INDEX");
    Tab_AddCol($tab,"DocumentID","unsigned int","0","INDEX");
    Tab_AddCol($tab,"ItemNo","smallint","0","INDEX");
    Tab_AddCol($tab,"Type","smallint","0","");
    Tab_AddCol($tab,"Text","longtext","","");
    Tab_AddCol($tab,"Running","unsigned int","0","INDEX");
    Tab_AddCol($tab,"Finished","unsigned int","0","INDEX");
    Tab_AddCol($tab,"CreatedByUserID","unsigned int","0","INDEX");
    $tab = "ZMRMVotes";
    Tab_Create($tab,"zmrm_votes");
    Tab_AddCol($tab,"MeetingID","unsigned int","0","INDEX");
    Tab_AddCol($tab,"DocumentID","unsigned int","0","INDEX");
    Tab_AddCol($tab,"ItemID","unsigned int","0","INDEX");
    Tab_AddCol($tab,"UserID","unsigned int","0","INDEX");
    Tab_AddCol($tab,"Username","VARCHAR(128)","","INDEX");
    Tab_AddCol($tab,"Vote","tinyint","0","INDEX");
    $tab = "ZMRMAttachments";
    Tab_Create($tab,"zmrm_attachments");
    Tab_AddCol($tab,"DocumentID","unsigned int","0","INDEX");
    Tab_AddCol($tab,"Title","text","","FULLTEXT");
    Tab_AddCol($tab,"Filename","text","","");
    Tab_AddCol($tab,"Extension","VARCHAR(5)","","INDEX");
    Tab_AddCol($tab,"Size","unsigned int","0","");
    Tab_AddCol($tab,"Published","tinyint","0","INDEX");
    Tab_AddCol($tab,"SortPos","smallint","0","INDEX");
    Tab_AddCol($tab,"CreatedByUserID","unsigned int","0","INDEX");}
if(Settings('EnableInstitutions',true)) {
    $tab = "Institutions";
    Tab_Create($tab,"institutions");
    Tab_AddCol($tab,"IconFilename","text","","");
    Tab_AddCol($tab,"IconWidth","smallint","0","");
    Tab_AddCol($tab,"IconHeight","smallint","0","");
    Tab_AddCol($tab,"CategoryID","unsigned int","0","INDEX");
    Tab_AddCol($tab,"Title","text","","FULLTEXT");
    Tab_AddCol($tab,"Note","text","","FULLTEXT");
    Tab_AddCol($tab,"Address","text","","FULLTEXT");
    Tab_AddCol($tab,"URL","text","","FULLTEXT");
    Tab_AddCol($tab,"Email","text","","FULLTEXT");
    Tab_AddCol($tab,"Telephone","text","","FULLTEXT");
    Tab_AddCol($tab,"MobilePhone","text","","FULLTEXT");
    Tab_AddCol($tab,"Fax","text","","FULLTEXT");
    Tab_AddCol($tab,"CreatedByUserID","unsigned int","0","INDEX");
    $tab = "InstitutionsCategories";
    Tab_Create($tab,"institutions_categories");
    Tab_AddCol($tab,"Title","text","","FULLTEXT");
    Tab_AddCol($tab,"CreatedByUserID","unsigned int","0","INDEX");}
if(Settings('EnableInstallationIDs')) {
    $tab = "InstallationIDs";
    Tab_Create($tab,"installation_ids");
    Tab_AddCol($tab,"AppID","tinyint","0","INDEX");
    Tab_AddCol($tab,"Version","smallint","0","INDEX");
    Tab_AddCol($tab,"Count","unsigned int","0","");}
if(Settings('EnableAPI')) {
    $tab = "APILogins";
    Tab_Create($tab,"api_logins");
    Tab_AddCol($tab,"UserID","unsigned int","0","INDEX");
    Tab_AddCol($tab,"InstID","unsigned int","0","INDEX");
    Tab_AddCol($tab,"AppID","tinyint","0","INDEX");
    Tab_AddCol($tab,"Version","smallint","0","INDEX");
    Tab_AddCol($tab,"IP","VARCHAR(15)","");
    $tab = "APITokens";
    Tab_Create($tab,"api_tokens");
    Tab_AddCol($tab,"UserID","unsigned int","0","INDEX");
    Tab_AddCol($tab,"Username","VARCHAR(128)","","");
    Tab_AddCol($tab,"Hash","VARCHAR(32)","","INDEX");
    Tab_AddCol($tab,"AppID","tinyint","0","INDEX");
    Tab_AddCol($tab,"LastLogin","int","0","INDEX");}
if(Settings('EnableUniqueUrlPaths')) {
    $tab = "UniqueUrlPaths";
    Tab_Create($tab,"unique_url_paths");
    Tab_AddCol($tab,"Type","tinyint","0","INDEX");
    Tab_AddCol($tab,"Path","VARCHAR(128)","","INDEX");
    Tab_AddCol($tab,"RedirectID","unsigned int","0","INDEX");}
if(defined("odoprag.cz")) {
    $tab = "Cars";
    Tab_Create($tab,"cars");
    Tab_AddCol($tab,"Title","text","","");
    Tab_AddCol($tab,"Deposit","int","0","");
    Tab_AddCol($tab,"MinDays","tinyint","0","");
    Tab_AddCol($tab,"SortPos","smallint","0","INDEX");
    Tab_AddCol($tab,"Text","text","","");
    Tab_AddCol($tab,"SpecialTitle","text","","");
    Tab_AddCol($tab,"FullTitle","text","","");
    Tab_AddCol($tab,"ShowInCalc","tinyint","0","");
    Tab_AddCol($tab,"AlbumID","unsigned int","0","INDEX");
    $tab = "Pricelist";
    Tab_Create($tab,"pricelist");
    Tab_AddCol($tab,"CarID","unsigned int","0","INDEX");
    Tab_AddCol($tab,"MaxDays","tinyint","0","");
    Tab_AddCol($tab,"Price","int","0","");
    Tab_AddCol($tab,"Sale","int","0","");
}

function TAB_GetSetForDB($table_name,$vals) {
    global $TABLE;
    $set = "";
    foreach($TABLE[$table_name] as $col_name => $value) {
        if($col_name != "TABLE_FullName" && $col_name != "TABLE_Name") {
            if(IsSet($vals[$col_name])) { $set.= "`".$col_name."` = '".DBText($vals[$col_name])."', "; }}}
    return $set;}
function TAB_FieldType($column_info) {
    $str = "!!! ".$column_info->type;
    $uns = "";
    switch($column_info->type) {
        case 1: $str = "tinyint"; break;
        case 2: $str = "smallint"; break;
        case 3: $str = "int"; break;
        case 7: $str = "timestamp"; break;
        case 8: $str = "bigint"; break;
        case 9: $str = "mediumint"; break;
        case 10: $str = "date"; break;
        case 11: $str = "time"; break;
        case 12: $str = "datetime"; break;
        case 13: $str = "year"; break;
        case 252: $str = "text"; break;
        case 253: $str = "varchar(".(($column_info->length)/3).")"; break;
        case 254: $str = "char(".(($column_info->length)/3).")"; break;
        default: WriteLog($str); break;}
    if($column_info->flags & 32) {
        $uns = "unsigned ";}
    return strtolower($uns.$str);}
function TAB_FieldIdOK($table,$col_name,$fields,$fieldsCount) {
    $found = false;
    for($aa=0; $aa<$fieldsCount; $aa++) {
        if($fields[$aa]->name == $col_name) {
            WriteLog("[TAB_FieldIdOK] aa = ".$aa.", col_name = ".$col_name);
            $column_info = $fields[$aa];
            $found = true;
            if(strtolower($table['type']) == TAB_FieldType($column_info)) {
                echo "[OK] ".$column_info->name.": type = ".TAB_FieldType($column_info)."<br />";
                return true;}
            else {
                echo "[TYPE in '".$column_info->name."'] ".strtolower($table['type'])." != ".TAB_FieldType($column_info)."<br />";}
            break;}}
    if(!$found) {
        echo "[NOT FOUND] ".$col_name."<br />";
        for($aa=0; $aa<$fieldsCount; $aa++) {
            echo $fields[$aa]->name."<br />";}
        WriteLog("[TAB_FieldIdOK] NOT FOUND ".$col_name);
        for($aa=0; $aa<$fieldsCount; $aa++) {
            WriteLog($fields[$aa]->name);}}
    return false;}
function TAB_Test($table_name) {
    global $TABLE, $MTPS, $DB;
    $request = "CREATE TABLE IF NOT EXISTS `".DBText($MTPS->MySQL_Name)."`.`".DBText($TABLE[$table_name]['TABLE_FullName'])."` (";
    $request.= "`ID` int(1) unsigned NOT NULL AUTO_INCREMENT, ";
    $request.= "PRIMARY KEY (`ID`) ";
    $request.= ") ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;";
    WriteLog("");
    WriteLog("[TAB_Test] --- ".$table_name." --- ".$request);
    $DB->Request($request);
    $field_list_result = $DB->ListFields($table_name);
    $fields = array();
    $fieldsCount = 0;
    $whileCounter = 0;
    while($column_info = $field_list_result->fetch_field()) {
        $fields[$fieldsCount] = new stdClass();
        $fields[$fieldsCount]->name = $column_info->name;
        $fields[$fieldsCount]->type = $column_info->type;
        $fields[$fieldsCount]->length = $column_info->length;
        $fields[$fieldsCount]->flags = $column_info->flags;
        WriteLog("[TAB_Test] fields name = ".$fields[$fieldsCount]->name.", fieldsCount = ".($fieldsCount+1));
        $fieldsCount++;
        if($whileCounter > 1000) { WriteLog("[TAB_Test] whileCounter ERROR!"); break; }
        $whileCounter++;}
    foreach($TABLE[$table_name] as $col_name => $value) {
        $logstr = "[TAB_Test] FOREACH col_name = ";
        $logstr.= $col_name;
        $logstr.= ", value = ";
        $logstr.= json_encode($value);
        WriteLog($logstr);
        if($col_name != "TABLE_FullName" && $col_name != "TABLE_Name") {
            WriteLog("[TAB_Test] IF col_name = ".$col_name.", value = ".json_encode($value));
            if(!TAB_FieldIdOK($TABLE[$table_name][$col_name],$col_name,$fields,$fieldsCount)) {
                WriteLog("[TAB_Test] col_name = ".$col_name);
                $after = "";
                switch(strtolower($TABLE[$table_name][$col_name]['type'])) {
                    case "text": $type = "TEXT"; $TABLE[$table_name][$col_name]['value'] = ""; $collate = true; break;
                    case "mediumtext": $type = "MEDIUMTEXT"; $TABLE[$table_name][$col_name]['value'] = ""; $collate = true; break;
                    case "longtext": $type = "LONGTEXT"; $TABLE[$table_name][$col_name]['value'] = ""; $collate = true; break;
                    case "int": $type = "INT(1)"; break;
                    case "unsigned int": $type = "INT(1) UNSIGNED"; break;
                    case "tinyint": $type = "TINYINT(1)"; break;
                    case "unsigned tinyint": $type = "TINYINT(1) UNSIGNED"; break;
                    case "smallint": $type = "SMALLINT(1)"; break;
                    case "unsigned smallint": $type = "SMALLINT(1) UNSIGNED"; break;
                    default: $type = $TABLE[$table_name][$col_name]['type']; break;}
                if($TABLE[$table_name][$col_name]['value'] != "") { $default = "DEFAULT '".DBText($TABLE[$table_name][$col_name]['value'])."'"; } else { $default = ""; }
                $request1 = "ALTER TABLE `".DBText($MTPS->MySQL_Name)."`.`".DBText($TABLE[$table_name]['TABLE_FullName'])."` ADD `".DBText($col_name)."` $type NOT NULL $default ".$TABLE[$table_name][$col_name]['extra']." $after;";
                $request2 = "ALTER TABLE `".DBText($MTPS->MySQL_Name)."`.`".DBText($TABLE[$table_name]['TABLE_FullName'])."` CHANGE `".DBText($col_name)."` `".DBText($col_name)."` $type NOT NULL $default ".$TABLE[$table_name][$col_name]['extra'].";";
                WriteLog("[TAB_Test] request1 = ".$request1);
                $DB->Request($request1);
                WriteLog("[TAB_Test] request2 = ".$request2);
                $DB->Request($request2);
                WriteLog("[TAB_Test] requests ok");
                $collate = false;
                $type2 = strtolower($type);
                if(strpos($type2,"text") !== false) { $collate = true; }
                else if(strpos($type2,"varchar") !== false) { $collate = true; }
                if($collate) { echo "ALTER TABLE `".DBText($MTPS->MySQL_Name)."`.`".DBText($TABLE[$table_name]['TABLE_FullName'])."` CHARACTER SET utf8 COLLATE utf8_czech_ci;<br />"; $DB->Request("ALTER TABLE `".DBText($MTPS->MySQL_Name)."`.`".DBText($TABLE[$table_name]['TABLE_FullName'])."` CHARACTER SET utf8 COLLATE utf8_czech_ci;"); }
                if($TABLE[$table_name][$col_name]['index'] != "") {
                    $request3 = "ALTER TABLE `".DBText($MTPS->MySQL_Name)."`.`".DBText($TABLE[$table_name]['TABLE_FullName'])."` DROP INDEX `".DBText($col_name)."`";
                    $DB->Request($request3);
                    $request4 = "ALTER TABLE `".DBText($MTPS->MySQL_Name)."`.`".DBText($TABLE[$table_name]['TABLE_FullName'])."` ADD ".DBText($TABLE[$table_name][$col_name]['index'])." (`".DBText($col_name)."`)";
                    $DB->Request($request4);}
                WriteLog("__________________________________________");}}}}
function TAB_GetEmptyArray($table_name) {
    global $TABLE, $MTPS, $DB;
    $array = array();
    foreach($TABLE[$table_name] as $col_name => $value) {
        if($col_name != "TABLE_FullName" && $col_name != "TABLE_Name") {
            $array[$col_name] = $TABLE[$table_name][$col_name]['value'];}}
    return $array;}
if(IsSet($MTPS->CreateTables) && $MTPS->CreateTables == true) {
    set_time_limit(180);
    set_time_limit(300);
    $count = 0;
    if(IsSet($_GET['TabPos'])) { $pos = $_GET['TabPos']; } else { $pos = 0; }
    foreach($TABLE as $table_name => $value) {
        if($count == $pos) {
            Header('Content-Type: text/html; charset=utf-8','',200);
            echo "<html><head><meta http-equiv=\"refresh\" content=\"0;url=".AddParam($urlWEB.'MTPSCreateTables','TabPos',$pos+1)."\"></head><body></body></html>";
            echo "<h1>Creating database tables. Please wait!</h1>";
            echo "<h2>".$table_name."</h2>";
            TAB_Test($table_name);
            echo WriteReports();
            echo "</body></html>";
            exit();}
        $count++;}
    if(IsSet($MTPS->SuperAdminEmail)) {
        if(!$User->CreateSuperAdminUser()) { DoExit(true); }}
    if(Settings('EnableUsersRights')) {$User->setDefaultUsersRights(); }
    Header('Content-Type: text/html; charset=utf-8','',200);
    echo "<html><head><meta http-equiv=\"refresh\" content=\"3;url=$urlWEB\"></head><body></body></html>";
    echo "<h1>Creating database tables</h1>";
    echo "<h2>DONE</h2>";
    echo "<a href=\"".$urlWEB."/MTPSCreateTables\">Do it again</a><br />";
    echo "<a href=\"$urlWEB\">Back to Homepage</a><br />";
    echo WriteReports();
    echo "</body></html>";
    exit();}
function WEB_Upload_ImageToCalendarItem(&$item_id,$calendar_item_id,$_files,&$response,&$path,&$ext) {
    global $Web, $MTPS;
    $response = "";
    $path = "";
    $ext = "";
    if($item_id == 0) {
        if($_files['Filedata']['type'] == "image/jpeg") { $ext = "jpg"; }
        if($_files['Filedata']['type'] == "image/png") { $ext = "png"; }
        if($_files['Filedata']['type'] == "image/gif") { $ext = "gif"; }
        if($ext != "") {
            $ext = strtolower($ext);
            $root = $GLOBALS['fileWEB'];
            $path = AddSlashToEnd("gallery/".LngPath()."calendar/".WEB_Calendar_GetItemPathByID($calendar_item_id,$MTPS->DefaultLanguage));
            if(is_dir($root.$path) || mkdir($root.$path,0775,true)) {
                if(WEB_Calendar_AddImage($item_id,$calendar_item_id,$ext,$response)) {
                    $ok = move_uploaded_file($_files['Filedata']['tmp_name'],$root.$path.$item_id.".".$ext);
                    return true;}
                else {
                    $response = "[WEB_Upload_ImageToCalendarItem] Unknown error!";}}
            else {
                $response = "[WEB_Upload_ImageToCalendarItem] Složku \"".$path."\" nelze vytvořit nebo otevřít!";}}
        else {
            $response = "[WEB_Upload_ImageToCalendarItem] Nepodporovaný formát obrázku \"".$_files['Filedata']['type']."\"!";}}
    else {
        $response = "[WEB_Upload_ImageToCalendarItem] Uložený obrázek nelze přepsat jiným obrázkem!";}
    DeleteFile($_files['Filedata']['tmp_name']);
    return false;}
function WEB_Upload_CalendarItemIcon($item_id,$_files,&$response,&$path,&$ext,&$filename,&$short_path) {
    global $Web, $MTPS;
    $response = "";
    $path = "";
    $ext = "";
    if($_files['Filedata']['type'] == "image/jpeg") { $ext = "jpg"; }
    if($_files['Filedata']['type'] == "image/png") { $ext = "png"; }
    if($_files['Filedata']['type'] == "image/gif") { $ext = "gif"; }
    if($ext != "") {
        $ext = strtolower($ext);
        $root = $GLOBALS['fileWEB'];
        $path = AddSlashToEnd("gallery/".LngPath()."calendar/".WEB_Calendar_GetItemPathByID($item_id,$MTPS->DefaultLanguage));
        $short_path = AddSlashToEnd(WEB_Calendar_GetItemPathByID($item_id,$MTPS->DefaultLanguage));
        if(is_dir($root.$path) || mkdir($root.$path,0775,true)) {
            $filename = "news-icon-".$item_id."_".Date("Y-m-d_His");
            return move_uploaded_file($_files['Filedata']['tmp_name'],$root.$path.$filename.".".$ext);}
        else {
            $response = "[WEB_Upload_CalendarItemIcon] Složku \"".$path."\" nelze vytvořit nebo otevřít!";}}
    else {
        $response = "[WEB_Upload_CalendarItemIcon] Nepodporovaný formát obrázku \"".$_files['Filedata']['type']."\"!";}
    DeleteFile($_files['Filedata']['tmp_name']);
    return false;}
function WEB_Upload_CalendarItemAttachment(&$attachment_id,$item_id,$_files,&$response,&$path,&$filename,&$ext,&$original_filename,&$filesize) {
    global $Web, $MTPS;
    $response = "";
    $path = "";
    $filename = "";
    $original_filename = "";
    $ext = "";
    $filesize = 0;
    $root = $GLOBALS['fileWEB'];
    $path = AddSlashToEnd("files/".LngPath()."calendar/".WEB_Calendar_GetItemPathByID($item_id,$MTPS->DefaultLanguage));
    if(is_dir($root.$path) || mkdir($root.$path,0775,true)) {
        if(IsSet($_files['Filedata']['name'])) {
            $ext = GetFileExtension($_files['Filedata']['name'],$original_filename);
            $original_filename = substr($original_filename,0,96);
            $filename = PageNameToDirName($original_filename);
            if(IsSet($_files['Filedata']['size'])) { $filesize = $_files['Filedata']['size']; }
            if(file_exists($root.$path.$filename.".".$ext)) {
                for($aa=0; $aa<1024; $aa++) {
                    if(!file_exists($root.$path.$filename."(".($aa+1).")".".".$ext)) {
                        $filename.= "(".($aa+1).")";
                        break;}}}
            if(WEB_Calendar_AddAttachmentFile($attachment_id,$item_id,$filename,$ext,$filesize,$response)) {
                $ok = move_uploaded_file($_files['Filedata']['tmp_name'],$root.$path.$filename.".".$ext);
                @chmod($root.$path.$filename.".".$ext,0775);
                return true;}
            else {
                $response = "[WEB_Upload_CalendarItemAttachment] Unknown error! ".$response;}}
        else {
            $response = "[WEB_Upload_CalendarItemAttachment] Chyba při nahrávání!<br /><b>Soubor je pravděpodobně příliš velký.</b><br />Maximální velikost souboru je ".ini_get("post_max_size").".";}}
    else {
        $response = "[WEB_Upload_CalendarItemAttachment] Složku \"".$path."\" nelze vytvořit nebo otevřít!";}
    DeleteFile($_files['Filedata']['tmp_name']);
    return false;}
function WEB_Upload_InstitutionsIcon($institution_id,$_files,&$response,&$path,&$ext,&$filename,&$short_path) {
    global $Web, $MTPS;
    $response = "";
    $path = "";
    $ext = "";
    if($_files['Filedata']['type'] == "image/jpeg") { $ext = "jpg"; }
    if($_files['Filedata']['type'] == "image/png") { $ext = "png"; }
    if($_files['Filedata']['type'] == "image/gif") { $ext = "gif"; }
    if($ext != "") {
        $ext = strtolower($ext);
        $root = $GLOBALS['fileWEB'];
        $path = AddSlashToEnd("gallery/institutions/".$institution_id);
        $short_path = AddSlashToEnd($institution_id);
        if(is_dir($root.$path) || mkdir($root.$path,0775,true)) {
            $filename = "institution-icon-".$institution_id."_".Date("Y-m-d_His");
            return move_uploaded_file($_files['Filedata']['tmp_name'],$root.$path.$filename.".".$ext);}
        else {
            $response = "[WEB_Upload_InstitutionsIcon] Složku \"".$path."\" nelze vytvořit nebo otevřít!";}}
    else {
        $response = "[WEB_Upload_InstitutionsIcon] Nepodporovaný formát obrázku \"".$_files['Filedata']['type']."\"!";}
    DeleteFile($_files['Filedata']['tmp_name']);
    return false;}
function WEB_Upload_NewsAttachment(&$attachment_id,$news_id,$_files,&$response,&$path,&$filename,&$ext,&$original_filename,&$filesize) {
    global $Web, $MTPS;
    $response = "";
    $path = "";
    $filename = "";
    $original_filename = "";
    $ext = "";
    $filesize = 0;
    $root = $GLOBALS['fileWEB'];
    $path = AddSlashToEnd("files/".LngPath()."news/".$Web->GetNewsPathByID($news_id,$MTPS->DefaultLanguage));
    WriteLog("[WEB_Upload_NewsAttachment] BEGIN");
    if(is_dir($root.$path) || mkdir($root.$path,0775,true)) {
        if(IsSet($_files['Filedata']['name'])) {
            $ext = GetFileExtension($_files['Filedata']['name'],$original_filename);
            $original_filename = substr($original_filename,0,96);
            $filename = PageNameToDirName($original_filename);
            if(IsSet($_files['Filedata']['size'])) { $filesize = $_files['Filedata']['size']; }
            WriteLog("[WEB_Upload_NewsAttachment] filename1 = ".$root.$path.$filename.".".$ext);
            WriteLog("[WEB_Upload_NewsAttachment] filesize = ".$filesize);
            if(file_exists($root.$path.$filename.".".$ext)) {
                for($aa=0; $aa<1024; $aa++) {
                    if(!file_exists($root.$path.$filename."(".($aa+1).")".".".$ext)) {
                        $filename.= "(".($aa+1).")";
                        break;}}}
            WriteLog("[WEB_Upload_NewsAttachment] filename2 = ".$root.$path.$filename.".".$ext);
            if(WEB_News_AddAttachmentFile($attachment_id,$news_id,$filename,$ext,$filesize,$response)) {
                WriteLog("[WEB_Upload_NewsAttachment] tmp_name = ".$_files['Filedata']['tmp_name']);
                $ok = move_uploaded_file($_files['Filedata']['tmp_name'],$root.$path.$filename.".".$ext);
                WriteLog("[WEB_Upload_NewsAttachment] move_uploaded_file = ".BoolToInt($ok));
                $ok = @chmod($root.$path.$filename.".".$ext,0775);
                WriteLog("[WEB_Upload_NewsAttachment] chmod = ".BoolToInt($ok));
                WriteLog("[WEB_Upload_NewsAttachment] END");
                return true;}
            else {
                $response = "[WEB_Upload_NewsAttachment] Unknown error! ".$response;}}
        else {
            $response = "[WEB_Upload_NewsAttachment] Chyba při nahrávání!<br /><b>Soubor je pravděpodobně příliš velký.</b><br />Maximální velikost souboru je ".ini_get("post_max_size").".";}}
    else {
        $response = "[WEB_Upload_NewsAttachment] Složku \"".$path."\" nelze vytvořit nebo otevřít!";}
    DeleteFile($_files['Filedata']['tmp_name']);
    WriteLog("[WEB_Upload_NewsAttachment] BAD-END");
    return false;}
function WEB_Upload_DocumentByDepartment(&$attachment_id,$department_id,$language,$_files,&$response,&$path,&$filename,&$ext,&$original_filename,&$filesize) {
    global $Web, $MTPS;
    $response = "";
    $path = "";
    $filename = "";
    $original_filename = "";
    $ext = "";
    $filesize = 0;
    $root = $GLOBALS['fileWEB'];
    $department_path = LngEx($language,"urlGENERAL");
    if($department_id > 0 && ($department_title = $Web->GetDepartmentTitleByID($department_id,$MTPS->DefaultLanguage)) != "") {
        $department_path = PageNameToDirName($department_title);}
    $path = AddSlashToEnd("files/".$language."/".LngEx($language,"urlDOCUMENTS")."/".LngEx($language,"urlDEPARTMENT")."/".$department_path);
    if(is_dir($root.$path) || mkdir($root.$path,0775,true)) {
        if(IsSet($_files['Filedata']['name'])) {
            $ext = GetFileExtension($_files['Filedata']['name'],$original_filename);
            $original_filename = substr($original_filename,0,96);
            $filename = PageNameToDirName($original_filename);
            if(IsSet($_files['Filedata']['size'])) { $filesize = $_files['Filedata']['size']; }
            if(file_exists($root.$path.$filename.".".$ext)) {
                for($aa=0; $aa<1024; $aa++) {
                    if(!file_exists($root.$path.$filename."(".($aa+1).")".".".$ext)) {
                        $filename.= "(".($aa+1).")";
                        break;}}}
            if($Web->Downloads_AddDocumentByDepartment($attachment_id,$department_id,$language,$filename,$ext,$filesize,$response)) {
                $ok = move_uploaded_file($_files['Filedata']['tmp_name'],$root.$path.$filename.".".$ext);
                @chmod($root.$path.$filename.".".$ext,0775);
                return true;}
            else {
                $response = "[WEB_Upload_DocumentByDepartment] Unknown error!";}}
        else {
            $response = "[WEB_Upload_DocumentByDepartment] Chyba při nahrávání!<br /><b>Soubor je pravděpodobně příliš velký.</b><br />Maximální velikost souboru je ".ini_get("post_max_size").".";}}
    else {
        $response = "[WEB_Upload_DocumentByDepartment] Složku \"".$path."\" nelze vytvořit nebo otevřít!";}
    DeleteFile($_files['Filedata']['tmp_name']);
    return false;}
function WEB_Upload_PageAttachment(&$attachment_id,$page_id,$_files,&$response,&$path,&$filename,&$ext,&$original_filename,&$filesize) {
    global $Web, $MTPS;
    $response = "";
    $path = "";
    $filename = "";
    $original_filename = "";
    $ext = "";
    $filesize = 0;
    $root = $GLOBALS['fileWEB'];
    $path = AddSlashToEnd("files/".LngPath()."pages/".$Web->GetPagePathByID($page_id,$MTPS->DefaultLanguage));
    if(is_dir($root.$path) || mkdir($root.$path,0775,true)) {
        if(IsSet($_files['Filedata']['name'])) {
            $ext = GetFileExtension($_files['Filedata']['name'],$original_filename);
            $original_filename = substr($original_filename,0,96);
            $filename = PageNameToDirName($original_filename);
            if(IsSet($_files['Filedata']['size'])) { $filesize = $_files['Filedata']['size']; }
            WriteLog("[WEB_Upload_PageAttachment] filename1 = ".$root.$path.$filename.".".$ext);
            WriteLog("[WEB_Upload_PageAttachment] filesize = ".$filesize);
            if(file_exists($root.$path.$filename.".".$ext)) {
                for($aa=0; $aa<1024; $aa++) {
                    if(!file_exists($root.$path.$filename."(".($aa+1).")".".".$ext)) {
                        $filename.= "(".($aa+1).")";
                        break;}}}
            WriteLog("[WEB_Upload_PageAttachment] filename2 = ".$root.$path.$filename.".".$ext);
            if($Web->Pages_AddAttachmentFile($attachment_id,$page_id,$filename,$ext,$filesize,$response)) {
                WriteLog("[WEB_Upload_PageAttachment] tmp_name = ".$_files['Filedata']['tmp_name']);
                $ok = move_uploaded_file($_files['Filedata']['tmp_name'],$root.$path.$filename.".".$ext);
                WriteLog("[WEB_Upload_PageAttachment] move_uploaded_file = ".BoolToInt($ok));
                $ok = @chmod($root.$path.$filename.".".$ext,0775);
                WriteLog("[WEB_Upload_PageAttachment] chmod = ".BoolToInt($ok));
                return true;}
            else {
                $response = "[WEB_Upload_PageAttachment] Unknown error!";}}
        else {
            $response = "[WEB_Upload_PageAttachment] Chyba při nahrávání!<br /><b>Soubor je pravděpodobně příliš velký.</b><br />Maximální velikost souboru je ".ini_get("post_max_size").".";}}
    else {
        $response = "[WEB_Upload_PageAttachment] Složku \"".$path."\" nelze vytvořit nebo otevřít!";}
    DeleteFile($_files['Filedata']['tmp_name']);
    return false;}
function WEB_Upload_ImageToPage(&$item_id,$page_id,$_files,&$response,&$path,&$ext) {
    global $Web, $MTPS;
    $response = "";
    $path = "";
    $ext = "";
    if($item_id == 0) {
        if($_files['Filedata']['type'] == "image/jpeg") { $ext = "jpg"; }
        if($_files['Filedata']['type'] == "image/png") { $ext = "png"; }
        if($_files['Filedata']['type'] == "image/gif") { $ext = "gif"; }
        if($ext != "") {
            $ext = strtolower($ext);
            $root = $GLOBALS['fileWEB'];
            $path = AddSlashToEnd("gallery/".LngPath()."pages/".$Web->GetPagePathByID($page_id,$MTPS->Language));
            if(is_dir($root.$path) || mkdir($root.$path,0775,true)) {
                if($Web->Pages_AddImage($item_id,$page_id,$ext,$response)) {
                    $ok = move_uploaded_file($_files['Filedata']['tmp_name'],$root.$path.$item_id.".".$ext);
                    return true;}
                else {
                    $response = "[WEB_Upload_ImageToPage] Unknown error!";}}
            else {
                $response = "[WEB_Upload_ImageToPage] Složku \"".$path."\" nelze vytvořit nebo otevřít!";}}
        else {
            $response = "[WEB_Upload_ImageToPage] Nepodporovaný formát obrázku \"".$_files['Filedata']['type']."\"!";}}
    else {
        $response = "[WEB_Upload_ImageToPage] Uložený obrázek nelze přepsat jiným obrázkem!";}
    DeleteFile($_files['Filedata']['tmp_name']);
    return false;}
function WEB_Upload_ImageToNews(&$item_id,$news_id,$_files,&$response,&$path,&$ext) {
    global $Web, $MTPS;
    $response = "";
    $path = "";
    $ext = "";
    if($item_id == 0) {
        if($_files['Filedata']['type'] == "image/jpeg") { $ext = "jpg"; }
        if($_files['Filedata']['type'] == "image/png") { $ext = "png"; }
        if($_files['Filedata']['type'] == "image/gif") { $ext = "gif"; }
        if($ext != "") {
            $ext = strtolower($ext);
            $root = $GLOBALS['fileWEB'];
            $path = AddSlashToEnd("gallery/".LngPath()."news/".$Web->GetNewsPathByID($news_id,$MTPS->DefaultLanguage));
            if(is_dir($root.$path) || mkdir($root.$path,0775,true)) {
                if(WEB_News_AddImage($item_id,$news_id,$ext,$response)) {
                    $ok = move_uploaded_file($_files['Filedata']['tmp_name'],$root.$path.$item_id.".".$ext);
                    return true;}
                else {
                    $response = "[WEB_Upload_ImageToNews] Unknown error!";}}
            else {
                $response = "[WEB_Upload_ImageToNews] Složku \"".$path."\" nelze vytvořit nebo otevřít!";}}
        else {
            $response = "[WEB_Upload_ImageToNews] Nepodporovaný formát obrázku \"".$_files['Filedata']['type']."\"!";}}
    else {
        $response = "[WEB_Upload_ImageToNews] Uložený obrázek nelze přepsat jiným obrázkem!";}
    DeleteFile($_files['Filedata']['tmp_name']);
    return false;}
function WEB_Upload_Image(&$item_id,$_files,&$response,&$path,&$ext) {
    $response = "";
    $path = "";
    $ext = "";
    if($item_id == 0) {
        if($_files['Filedata']['type'] == "image/jpeg") { $ext = "jpg"; }
        if($_files['Filedata']['type'] == "image/png") { $ext = "png"; }
        if($_files['Filedata']['type'] == "image/gif") { $ext = "gif"; }
        if($ext != "") {
            $root = $GLOBALS['fileWEB'];
            $path = "gallery/".LngPath().Date("Y")."/".Date("m")."/".Date("d")."/";
            if(is_dir($root.$path) || mkdir($root.$path,0775,true)) {
                list($width, $height, $type, $attr) = getimagesize($_files['Filedata']['tmp_name']);
                if(WEB_Gallery_AddImage($item_id,$path,$ext,$width,$height,$response)) {
                    $ok = move_uploaded_file($_files['Filedata']['tmp_name'],$root.$path.$item_id.".".$ext);
                    return true;}
                else {
                    $response = "[WEB_Upload_Image] Unknown error!";}}
            else {
                $response = "[WEB_Upload_Image] Složku \"".$path."\" nelze vytvořit nebo otevřít!";}}
        else {
            $response = "[WEB_Upload_Image] Nepodporovaný formát obrázku \"".$_files['Filedata']['type']."\"!";}}
    else {
        $response = "[WEB_Upload_Image] Uložený obrázek nelze přepsat jiným obrázkem!";}
    DeleteFile($_files['Filedata']['tmp_name']);
    return false;}
function WEB_Upload_ZMRMAttachment(&$attachment_id,$zmrm_id,$_files,&$response,&$path,&$filename,&$ext,&$original_filename,&$filesize) {
    global $Web, $MTPS;
    $response = "";
    $path = "";
    $filename = "";
    $original_filename = "";
    $ext = "";
    $filesize = 0;
    $root = $GLOBALS['fileWEB'];
    $path = AddSlashToEnd("files/".LngPath()."zmrm/".$Web->GetZMRMPathByID($zmrm_id,$MTPS->DefaultLanguage));
    if(is_dir($root.$path) || mkdir($root.$path,0775,true)) {
        if(IsSet($_files['Filedata']['name'])) {
            $ext = GetFileExtension($_files['Filedata']['name'],$original_filename);
            $original_filename = substr($original_filename,0,96);
            $filename = PageNameToDirName($original_filename);
            if(IsSet($_files['Filedata']['size'])) { $filesize = $_files['Filedata']['size']; }
            if(file_exists($root.$path.$filename.".".$ext)) {
                for($aa=0; $aa<1024; $aa++) {
                    if(!file_exists($root.$path.$filename."(".($aa+1).")".".".$ext)) {
                        $filename.= "(".($aa+1).")";
                        break;}}}
            if(WEB_ZMRM_AddAttachmentFile($attachment_id,$zmrm_id,$filename,$ext,$filesize,$response)) {
                $ok = move_uploaded_file($_files['Filedata']['tmp_name'],$root.$path.$filename.".".$ext);
                @chmod($root.$path.$filename.".".$ext,0775);
                return true;}
            else {
                $response = "[WEB_Upload_ZMRMAttachment] Unknown error! ".$response;}}
        else {
            $response = "[WEB_Upload_ZMRMAttachment] Chyba při nahrávání!<br /><b>Soubor je pravděpodobně příliš velký.</b><br />Maximální velikost souboru je ".ini_get("post_max_size").".";}}
    else {
        $response = "[WEB_Upload_ZMRMAttachment] Složku \"".$path."\" nelze vytvořit nebo otevřít!";}
    DeleteFile($_files['Filedata']['tmp_name']);
    return false;}
function WEB_Upload_EUDAttachment(&$attachment_id,$eud_id,$_files,&$response,&$path,&$filename,&$ext,&$original_filename,&$filesize) {
    global $Web, $MTPS;
    $response = "";
    $path = "";
    $filename = "";
    $original_filename = "";
    $ext = "";
    $filesize = 0;
    $root = $GLOBALS['fileWEB'];
    $path = AddSlashToEnd("files/".LngPath()."eud/".WEB_EUD_GetEUDPathByID($eud_id));
    if(is_dir($root.$path) || mkdir($root.$path,0775,true)) {
        if(IsSet($_files['Filedata']['name'])) {
            $ext = GetFileExtension($_files['Filedata']['name'],$original_filename);
            $original_filename = substr($original_filename,0,96);
            $filename = PageNameToDirName($original_filename);
            if(IsSet($_files['Filedata']['size'])) { $filesize = $_files['Filedata']['size']; }
            if(file_exists($root.$path.$filename.".".$ext)) {
                for($aa=0; $aa<1024; $aa++) {
                    if(!file_exists($root.$path.$filename."(".($aa+1).")".".".$ext)) {
                        $filename.= "(".($aa+1).")";
                        break;}}}
            if(WEB_EUD_AddAttachmentFile($attachment_id,$eud_id,$filename,$ext,$filesize,$response)) {
                $ok = move_uploaded_file($_files['Filedata']['tmp_name'],$root.$path.$filename.".".$ext);
                @chmod($root.$path.$filename.".".$ext,0775);
                return true;}
            else {
                $response = "[WEB_Upload_EUDAttachment] Unknown error! ".$response;}}
        else {
            $response = "[WEB_Upload_EUDAttachment] Chyba při nahrávání!<br /><b>Soubor je pravděpodobně příliš velký.</b><br />Maximální velikost souboru je ".ini_get("post_max_size").".";}}
    else {
        $response = "[WEB_Upload_EUDAttachment] Složku \"".$path."\" nelze vytvořit nebo otevřít!";}
    DeleteFile($_files['Filedata']['tmp_name']);
    return false;}
function WEB_Upload_ObrazDokladu(&$attachment_id,$doklad_id,$_files,&$response,&$path,&$filename,&$ext,&$original_filename,&$filesize) {
    global $Web, $MTPS;
    $response = "";
    $path = "";
    $filename = "";
    $original_filename = "";
    $ext = "";
    $filesize = 0;
    $root = $GLOBALS['fileWEB'];
    $path = AddSlashToEnd("files/".LngPath()."doklady/".$doklad_id);
    if(is_dir($root.$path) || mkdir($root.$path,0775,true)) {
        if(IsSet($_files['Filedata']['name'])) {
            $ext = GetFileExtension($_files['Filedata']['name'],$original_filename);
            $original_filename = substr($original_filename,0,96);
            $filename = PageNameToDirName($original_filename);
            if(IsSet($_files['Filedata']['size'])) { $filesize = $_files['Filedata']['size']; }
            if(file_exists($root.$path.$filename.".".$ext)) {
                for($aa=0; $aa<1024; $aa++) {
                    if(!file_exists($root.$path.$filename."(".($aa+1).")".".".$ext)) {
                        $filename.= "(".($aa+1).")";
                        break;}}}
            if(Sportovci_AddObrazDokladuFile($attachment_id,$doklad_id,$filename,$ext,$filesize,$response)) {
                $ok = move_uploaded_file($_files['Filedata']['tmp_name'],$root.$path.$filename.".".$ext);
                @chmod($root.$path.$filename.".".$ext,0775);
                return true;}
            else {
                $response = "[WEB_Upload_ObrazDokladu] Unknown error! ".$response;}}
        else {
            $response = "[WEB_Upload_ObrazDokladu] Chyba při nahrávání!<br /><b>Soubor je pravděpodobně příliš velký.</b><br />Maximální velikost souboru je ".ini_get("post_max_size").".";}}
    else {
        $response = "[WEB_Upload_ObrazDokladu] Složku \"".$path."\" nelze vytvořit nebo otevřít!";}
    DeleteFile($_files['Filedata']['tmp_name']);
    return false;}
function WEB_Upload_PrilohaZadosti(&$attachment_id,$zadost_id,$_files,&$response,&$path,&$filename,&$ext,&$original_filename,&$filesize) {
    global $Web, $MTPS;
    $response = "";
    $path = "";
    $filename = "";
    $original_filename = "";
    $ext = "";
    $filesize = 0;
    $root = $GLOBALS['fileWEB'];
    $path = AddSlashToEnd("files/".LngPath()."zadosti/".$zadost_id);
    if(is_dir($root.$path) || mkdir($root.$path,0775,true)) {
        if(IsSet($_files['Filedata']['name'])) {
            $ext = GetFileExtension($_files['Filedata']['name'],$original_filename);
            $original_filename = substr($original_filename,0,96);
            $filename = PageNameToDirName($original_filename);
            if(IsSet($_files['Filedata']['size'])) { $filesize = $_files['Filedata']['size']; }
            if(file_exists($root.$path.$filename.".".$ext)) {
                for($aa=0; $aa<1024; $aa++) {
                    if(!file_exists($root.$path.$filename."(".($aa+1).")".".".$ext)) {
                        $filename.= "(".($aa+1).")";
                        break;}}}
            if(Sportovci_AddPrilohaZadostiFile($attachment_id,$zadost_id,$filename,$ext,$filesize,$response)) {
                $ok = move_uploaded_file($_files['Filedata']['tmp_name'],$root.$path.$filename.".".$ext);
                @chmod($root.$path.$filename.".".$ext,0775);
                return true;}
            else {
                $response = "[WEB_Upload_PrilohaZadosti] Unknown error! ".$response;}}
        else {
            $response = "[WEB_Upload_PrilohaZadosti] Chyba při nahrávání!<br /><b>Soubor je pravděpodobně příliš velký.</b><br />Maximální velikost souboru je ".ini_get("post_max_size").".";}}
    else {
        $response = "[WEB_Upload_PrilohaZadosti] Složku \"".$path."\" nelze vytvořit nebo otevřít!";}
    DeleteFile($_files['Filedata']['tmp_name']);
    return false;}
function WEB_Gallery_WriteRandomImage($width) {
    global $DB;
    if(($rows = $DB->Select("GalleryImages","`Published`>0",$count,"RAND()","1")) !== false && $count > 0) {
        return "<img src=\"".$GLOBALS['urlWEB']."image/".$rows[0]->ID."_w".$width.".".$rows[0]->Extension."\" style=\"width: ".$width."px;\" alt=\"".$rows[0]->Title."\" />";}
    return "";}
function WEB_Gallery_ShowImage() {
    global $DB, $MTPS;
    $ext = "";
    $filename = "";
    $path = "";
    $image_id = 0;
    $image_width = 0;
    $image_height = 0;
    $image_atleast = 0;
    $image_square = 0;
    switch($MTPS->PathTwo) {
        case "file":
            $ext = GetFileExtension($MTPS->Path[$MTPS->PathCount-1],$filename);
            if(IsSet($_GET['Square'])) { $image_square = $_GET['Square']; }
            if(IsSet($_GET['AtLeast'])) { $image_atleast = $_GET['AtLeast']; }
            if(IsSet($_GET['Width'])) { $image_width = $_GET['Width']; }
            if(IsSet($_GET['Height'])) { $image_width = $_GET['Height']; }
            for($aa=2; $aa<$MTPS->PathCount-1; $aa++) { $path.= $MTPS->Path[$aa]."/"; }
            return WEB_Gallery_ShowImage_FromSourceFile($filename,$ext,$path,$image_width,$image_height,$image_atleast,$image_square);
        default:
            $ext = GetFileExtension($MTPS->PathTwo,$filename);
            if($filename != "" && $ext != "") {
                if(is_numeric($filename)) { $image_id = $filename; }
                else {
                    $data = explode("_",$filename);
                    if(IsSet($data[0])) { $image_id = $data[0]; }
                    if(IsSet($data[1])) {
                        if($data[1][0] == "w") { $image_width = substr($data[1],1); }
                        if($data[1][0] == "h") { $image_height = substr($data[1],1); }}
                    if(IsSet($data[2])) {
                        if($data[2][0] == "w") { $image_width = substr($data[2],1); }
                        if($data[2][0] == "h") { $image_height = substr($data[2],1); }}}}
            if(($image = WEB_Gallery_LoadImage($image_id)) !== false) {
                return WEB_Gallery_ShowImage_FromSourceFile($image->ID,$image->Extension,$image->Path,$image_width,$image_height,$image_atleast,$image_square);}
            break;}
    return "";}
function WEB_Gallery_ShowImage_FromSourceFile($image_name,$ext,$image_path,$image_width,$image_height,$image_atleast=0,$image_square=0) {
    $image_width = ToNum($image_width);
    $image_height = ToNum($image_height);
    if($image_width == 0 && $image_height == 0 && $image_atleast == 0 && $image_square == 0) { $remoteImage = $GLOBALS['fileWEB'].$image_path.$image_name.".".$ext; }
    if($image_width > 0 && $image_height == 0) { @is_dir($GLOBALS['fileWEB']."cache/".LngPath().$image_path); @mkdir($GLOBALS['fileWEB']."cache/".LngPath().$image_path,0775,true); $remoteImage = $GLOBALS['fileWEB']."cache/".LngPath().$image_path.$image_name."_w".$image_width.".".$ext; }
    if($image_width == 0 && $image_height > 0) { @is_dir($GLOBALS['fileWEB']."cache/".LngPath().$image_path); @mkdir($GLOBALS['fileWEB']."cache/".LngPath().$image_path,0775,true); $remoteImage = $GLOBALS['fileWEB']."cache/".LngPath().$image_path.$image_name."_h".$image_height.".".$ext; }
    if($image_width == 0 && $image_height == 0 && $image_atleast > 0) { @is_dir($GLOBALS['fileWEB']."cache/".LngPath().$image_path); @mkdir($GLOBALS['fileWEB']."cache/".LngPath().$image_path,0775,true); $remoteImage = $GLOBALS['fileWEB']."cache/".LngPath().$image_path.$image_name."_a".$image_atleast.".".$ext; }
    if($image_width == 0 && $image_height == 0 && $image_atleast == 0 && $image_square > 0) { @is_dir($GLOBALS['fileWEB']."cache/".LngPath().$image_path); @mkdir($GLOBALS['fileWEB']."cache/".LngPath().$image_path,0775,true); $remoteImage = $GLOBALS['fileWEB']."cache/".LngPath().$image_path.$image_name."_s".$image_square.".".$ext; }
    if(!file_exists($remoteImage) && ($image_width != 0 || $image_height != 0 || $image_atleast != 0 || $image_square != 0)) {
        $src_img = false;
        if(strtolower($ext) == "jpg") {
            $src_img = @imagecreatefromjpeg($GLOBALS['fileWEB'].$image_path.$image_name.".".$ext);
            if(!$src_img) {
                $remoteImage = $GLOBALS['fileWEB'].$image_path.$image_name.".".$ext;}}
        if(strtolower($ext) == "gif") { $src_img = imagecreatefromgif($GLOBALS['fileWEB'].$image_path.$image_name.".".$ext); }
        if(strtolower($ext) == "png") { $src_img = imagecreatefrompng($GLOBALS['fileWEB'].$image_path.$image_name.".".$ext); }
        if($src_img) {
            list($srcWidth,$srcHeight,$type,$attr) = getimagesize($GLOBALS['fileWEB'].$image_path.$image_name.".".$ext);
            if($image_width > 0 && $image_height == 0) {
                $destWidth = $image_width;
                $destHeight = (($image_width*$srcHeight)/$srcWidth);}
            if($image_width == 0 && $image_height > 0) {
                $destHeight = $image_height;
                $destWidth = (($image_height*$srcWidth)/$srcHeight);}
            if($image_width > 0 && $image_height > 0) {
                $destWidth = $image_width;
                $destHeight = $image_height;}
            if($image_atleast > 0) {
                if($srcHeight < $srcWidth) {
                    $destHeight = $image_atleast;
                    $destWidth = (($image_atleast*$srcWidth)/$srcHeight);}
                else {
                    $destWidth = $image_atleast;
                    $destHeight = (($image_atleast*$srcHeight)/$srcWidth);}}
            $square_offset_x = 0; $square_offset_y = 0;
            $square_dimension = 0;
            if($image_square > 0) {
                if($srcHeight < $srcWidth) {
                    $square_dimension = $srcHeight;
                    $square_offset_x = ($srcWidth-$srcHeight)/2;
                    $destHeight = $image_square;
                    $destWidth = $image_square;}
                else {
                    $square_dimension = $srcWidth;
                    $square_offset_y = ($srcHeight-$srcWidth)/2;
                    $destWidth = $image_square;
                    $destHeight = $image_square;}}
            $dst_img = imagecreatetruecolor($destWidth,$destHeight);
            if(strtolower($ext) == "png") {
                imagealphablending($dst_img,false);
                imagesavealpha($dst_img,true);
                $transparent = imagecolorallocatealpha($dst_img, 255, 255, 255, 127);
                imagefilledrectangle($dst_img,0,0,$destWidth,$destHeight,$transparent);}
            if($image_square > 0) {
                imagecopyresampled($dst_img,$src_img,0,0,$square_offset_x,$square_offset_y,$destWidth,$destHeight,$square_dimension,$square_dimension);}
            else {
                imagecopyresampled($dst_img,$src_img,0,0,0,0,$destWidth,$destHeight,$srcWidth,$srcHeight);}
            if(strtolower($ext) == "jpg") { imagejpeg($dst_img,$remoteImage,95); }
            if(strtolower($ext) == "gif") { imagegif($dst_img,$remoteImage); }
            if(strtolower($ext) == "png") { imagepng($dst_img,$remoteImage); }
            imagedestroy($dst_img);
            imagedestroy($src_img);}}
    if(file_exists($remoteImage)) {
        $imginfo = getimagesize($remoteImage);
        Header("Content-type: ".$imginfo['mime'],'',200);
        Header('Expires: '.gmdate('D, d M Y H:i:s \G\M\T',time()+(3*31*24*60*60)));
        Header("Cache-Control: max-age=29030400");
        header_remove("Pragma");
        readfile($remoteImage);
        die("");}
    else {
        Header("Content-type: text",'',404);}
    return "";}
function WEB_Gallery_LoadImage($image_id) {
    global $DB;
    if(($rows = $DB->Select("GalleryImages","`ID`=".DBText($image_id)." AND `Published`>0",$count)) !== false && $count > 0) {
        return $rows[0];}
    return false;}
function WEB_Gallery_AddImage(&$image_id,$path,$extension,$width,$height,&$response) {
    global $DB, $MTPS, $User;
    $response = "";
    if($image_id == 0) {
        if(IsSet($data)) { UnSet($data); }
        $data['Path'] = $path;
        $data['Extension'] = $extension;
        $data['ImageWidth'] = $width;
        $data['ImageHeight'] = $height;
        $data['CreatedByUserID'] = GetUserAccountID();
        if(($image_id = $DB->Insert("GalleryImages",$data,$response)) !== false) {
            return true;}}
    if($response == "") { $response = "[WEB_Gallery_AddImage] Unknown error!"; }
    return false;}
function WEB_Gallery_EditImage(&$image_id,$_values,&$response) {
    global $DB, $MTPS, $User;
    $response = "";
    if($image_id > 0) {
        $set = "`AlbumID` = '".DBText($_values['AlbumID'])."', ";
        $set.= "`Title` = '".DBText($_values['Title'])."', ";
        $set.= "`Text` = '".DBText($_values['Text'])."', ";
        $set.= "`Published` = '".DBText(Time())."', ";
        if($DB->Update("GalleryImages",$set,"`ID`=".DBText($image_id))) {
            return true;}}
    if($response == "") { $response = "[WEB_Gallery_EditImage] Unknown error!"; }
    return false;}
function WEB_Gallery_DeleteAlbum($album_id,&$response) {
    global $DB;
    $response = "";
    if(($rows = $DB->Select("GalleryImages","`AlbumID`=".DBText($album_id),$count,"`Created` DESC")) !== false && $count == 0) {
        if($DB->Delete("GalleryAlbums","`ID`=".DBText($album_id))) {
            return true;}}
    else {
        $response = Lng('AlbumMustBeEmpty');}
    return false;}
function WEB_Gallery_EditAlbum(&$album_id,$_values,&$arr) {
    global $DB, $MTPS, $User;
    unset($arr['Response']);
    if($album_id == 0) {
        if(IsSet($data)) { UnSet($data); }
        $data['Title'] = $_values['Title'];
        $data['Date'] = $_values['Date_Date'];
        $data['Visibility'] = $_values['Visibility'];
        $data['CreatedByUserID'] = GetUserAccountID();
        $arr['AlbumName'] = PageNameToDirName($_values['Title']);
        if(($album_id = $DB->Insert("GalleryAlbums",$data)) !== false) {
            return true;}}
    else {
        if(($album = galleryLoadAlbum($album_id)) !== false) {
            $arr['AlbumName'] = PageNameToDirName($album->Title);}
        $set = "`Title` = '".DBText($_values['Title'])."', ";
        $set.= "`Date` = '".DBText($_values['Date_Date'])."', ";
        $set.= "`Visibility` = '".DBText($_values['Visibility'])."', ";
        if($DB->Update("GalleryAlbums",$set,"`ID`=".DBText($album_id))) {
            return true;}}
    $arr['Response'] = "[WEB::Gallery_EditAlbum] Unknown error!";
    return false;}
function WEB_Gallery_LoadAlbum($id) {
    global $DB;
    if($id > 0) {
        if(($albums = $DB->Select("GalleryAlbums","`ID`=".DBText($id),$count,"`Date` DESC, `Title` ASC")) !== false && $count > 0) {
            return $albums[0];}
        else {
            AddError("[WEB_Gallery_LoadAlbum] Album id: ".$id." not found! count = ".$count);}}
    else {
        WriteLog("[WEB_Gallery_LoadAlbum] id:".$id." < 0");}
    return false;}
function WEB_Gallery_LoadAlbums(&$count) {
    global $DB;
    $count = 0;
    if(($albums = $DB->Select("GalleryAlbums","",$count,"`Date` DESC, `Title` ASC")) !== false && $count >= 0) {
        return $albums;}
    return false;}
function WEB_Gallery_GetAlbum($album_id) {
    global $DB;
    if(($albums = $DB->Select("GalleryAlbums","`ID`=".DBText($album_id),$count)) !== false && $count >= 0) {
        return $albums[0];}
    return false;}
function WEB_Gallery_LoadListOfImages($album_id,&$count) {
    global $DB, $User;
    $count = 0;
    if($album_id <= 0) { $where = "`Published`>0"; } else { $where = "`Published`>0 AND `AlbumID`=".DBText($album_id); }
    if(($images = $DB->Select("GalleryImages",$where,$count,"`SortPos` DESC, `Created` DESC")) !== false && $count >= 0) {
        for($aa=0; $aa<$count; $aa++) {
            $user = $User->LoadUserByID($images[$aa]->CreatedByUserID);
            $images[$aa]->CreatedByUserID_FullName = $user->FirstName." ".$user->LastName;}
        return $images;}
    return false;}
function WEB_Gallery_WriteAllAlbums() {
    global $MTPS;
    $image_height = 150;
    $str = "";
    $show_squares = Settings('GalleryShowSquares');
    $albums = WEB_Gallery_LoadAlbums($albums_count);
    if(CanAdmin()) {
        $str.= "<p>";
        $str.= "Administrace: ";
        $str.= "<a href=\"\" onclick=\"Gallery_EditAlbum(0);return false;\">".Lng('NewAlbum')."</a>";
        $str.= "</p>";}
    $str.= "<div class=\"galleryAllAlbums\">";
    for($aa=0; $aa<$albums_count; $aa++) {
        $str.= "<a class=\"galleryAlbumLink\" href=\"".$GLOBALS['NavigationLastURL'].$albums[$aa]->ID."-".PageNameToDirName($albums[$aa]->Title)."\" title=\"".$albums[$aa]->Title."\" style=\"background-image:url('".$GLOBALS['urlIMG']."folder-128x128.png');\">";
        $str.= "<p>".$albums[$aa]->Title."</p>";
        $str.= "</a>";}
    $str.= "</div>";
    return $str;}
function WEB_Gallery_WriteAlbum($album_id,$show_title=true,$show_back=true,$params=array()) {
    global $MTPS;
    $image_height = 150;
    $str = "";
    $show_squares = Settings('GalleryShowSquares');
    $str.= "<div class=\"galleryOneAlbum\">";
    if($show_back) {
        $str.= "<p>";
        $str.= "&larr;&nbsp;<a href=\"".$GLOBALS['NavigationLastURL']."\">Zpět na všechna alba</a>";
        $str.= "</p>";}
    if(CanAdmin()) {
        $str.= "<p class=\"galleryAdministration\">";
        $str.= "Administrace: ";
        $str.= "<a href=\"\" onclick=\"Gallery_EditAlbum(".$album_id.");return false;\">".Lng('EditAlbum')."</a> | ";
        $str.= "<a href=\"\" onclick=\"Gallery_UploadPictures(".$album_id.");return false;\">Nahrát obrázky</a> ";
        $str.= "</p>";}
    $album = WEB_Gallery_LoadAlbum($album_id);
    if($album === false) { return "Gallery album ".$album_id." not found!<br />"; }
    $images = WEB_Gallery_LoadListOfImages($album->ID,$images_count);
    if($show_title) {
        $str.= "<h1>".$album->Title."</h1>";}
    if($images_count > 0) {
        $str.= "<div class=\"gallery\">";
        for($bb=0; $bb<$images_count; $bb++) {
            if(IsSet($params['width']) && is_numeric($params['width']) && $params['width'] > 0) {
                $src = $GLOBALS['urlWEB']."image/".$images[$bb]->ID."_w".$params['width'].".".$images[$bb]->Extension;
                $st = "width:".$params['width']."px;max-width:100%;";}
            else if($show_squares) {
                $src = $GLOBALS['urlWEB']."image/file/".$images[$bb]->Path.$images[$bb]->ID.".".$images[$bb]->Extension."?Square=".$MTPS->Settings['GallerySquaresSize'];
                $st = "width:".$MTPS->Settings['GallerySquaresSize']."px;height:".$MTPS->Settings['GallerySquaresSize']."px;";}
            else {
                $src = $GLOBALS['urlWEB']."image/".$images[$bb]->ID."_h".$image_height.".".$images[$bb]->Extension;
                $st = "height: ".$image_height."px;";}
            $str.= "<a class=\"gallery_link\" onclick=\"galleryShowFullImage(".$images[$bb]->AlbumID.",".$images[$bb]->ID.");Stop();return false;\" target=\"_blank\" href=\"".$GLOBALS['urlWEB'].$images[$bb]->Path.$images[$bb]->ID.".".$images[$bb]->Extension."\" title=\"".$images[$bb]->Title."\">";
            if(CanAdmin()) {
                $str.= "<img src=\"".$GLOBALS['urlIMG']."delete-red-32x32.png\" onclick=\"galleryDeleteImage(".$images[$bb]->AlbumID.",".$images[$bb]->ID.");Stop();return false;\" class=\"gallery_image_admin_icon\" alt=\"".Lng('DeleteImage')."\" />";}
            $str.= "<img src=\"".$src."\" class=\"gallery_img\" style=\"".$st."\" alt=\"".$images[$bb]->Title."\" />";
            $str.= "</a>";}
        $str.= "</div>";
        if($show_back) {
            $str.= "<p>";
            $str.= "&larr;&nbsp;<a href=\"".$GLOBALS['NavigationLastURL']."\">Zpět na všechna alba</a>";
            $str.= "</p>";}}
    else {
        $str.= "<p>Album je prázdné.</p>";}
    $str.= "</div>";
    return $str;}
function galleryLoadImage($vals,&$arr=null) {
    global $DB;
    unset($arr['Response']);
    if(IsSet($vals['AlbumID']) && is_numeric($vals['AlbumID']) && $vals['AlbumID'] >= 0 && IsSet($vals['ImageID']) && is_numeric($vals['ImageID']) && $vals['ImageID'] >= 0) {
        if(($rows = $DB->Select("GalleryImages","`AlbumID`=".DBText($vals['AlbumID'])." AND `ID`=".DBText($vals['ImageID']),$count)) !== false && $count > 0) {
            $arr['Item'] = $rows[0];
            return true;}}
    return false;}
function galleryDeleteImage($vals,&$arr=null) {
    global $DB;
    unset($arr['Response']);
    if(IsSet($vals['AlbumID']) && is_numeric($vals['AlbumID']) && $vals['AlbumID'] >= 0 && IsSet($vals['ImageID']) && is_numeric($vals['ImageID']) && $vals['ImageID'] >= 0) {
        if(CanAdmin()) {
            if(($rows = $DB->Select("GalleryImages","`AlbumID`=".DBText($vals['AlbumID'])." AND `ID`=".DBText($vals['ImageID']),$count)) !== false && $count > 0) {
                $image = $rows[0];
                $file = $GLOBALS['fileWEB'].$image->Path."/".$image->ID.".".$image->Extension;
                if($DB->Delete("GalleryImages","`AlbumID`=".DBText($vals['AlbumID'])." AND `ID`=".DBText($vals['ImageID']),$arr['Response'])) {
                    if(@file_exists($file)) {
                        @unlink($file);}
                    return true;}}}}
    return false;}
function galleryLoadAlbum($vals,&$arr=null) {
    global $DB;
    if(is_numeric($vals) && $arr === null) {
        $item_id = $vals;
        $vals = array();
        $vals['ItemID'] = $item_id;}
    unset($arr['Response']);
    if(IsSet($vals['ItemID']) && is_numeric($vals['ItemID']) && $vals['ItemID'] >= 0) {
        if(($rows = $DB->Select("GalleryAlbums","`ID`=".DBText($vals['ItemID']),$count)) !== false && $count > 0) {
            if(IsSet($item_id)) {
                return $rows[0];}
            $arr['Item'] = $rows[0];
            return true;}}
    return false;}
function galleryLoadFullAlbum($vals,&$arr=null) {
    global $DB;
    unset($arr['Response']);
    if(IsSet($vals['AlbumID']) && is_numeric($vals['AlbumID']) && $vals['AlbumID'] >= 0) {
        if(($rows = $DB->Select("GalleryAlbums","`ID`=".DBText($vals['AlbumID']),$count)) !== false && $count > 0) {
            $arr['Album'] = $rows[0];
            if(($arr['Images'] = $DB->Select("GalleryImages","`AlbumID`=".DBText($vals['AlbumID'])." AND `Published`>0",$arr['ImagesCount'],"`SortPos` DESC, `Created` DESC")) !== false && $arr['ImagesCount'] > 0) {
                return true;}}}
    return false;}
function galleryGetImageFromBASE64($base64,$image_orientation,&$width,&$height) {
    $imageData = str_replace('data:image/png;base64,','',$base64);
    $imageData = str_replace(' ', '+', $imageData);
    $data = base64_decode($imageData);
    $source = imagecreatefromstring($data);
    $source = galleryAutopudateImageOrientation($source,$image_orientation);
    $width = imagesx($source);
    $height = imagesy($source);
    return $source;}
function galleryAutopudateImageOrientation($source,$image_orientation) {
    switch($image_orientation) {
        case 1: case "": break;
        case 3: $source = imagerotate($source,180,0); break;
        case 6: $source = imagerotate($source,270,0); break;
        case 8: $source = imagerotate($source,90,0); break;
        default: WriteLog("[galleryAutopudateImageOrientation] ImageOrientation = ".$image_orientation); break;}
    return $source;}
function galleryUploadMultipleImages($vals,&$arr) {
    global $DB, $User, $Web;
    unset($arr['Response']);
    if(CanAdmin()) {
        if(IsSet($vals['AlbumID']) && is_numeric($vals['AlbumID']) && $vals['AlbumID'] > 0 && IsSet($vals['ImageData'])) {
            if(($album = galleryLoadAlbum($vals['AlbumID'])) !== false) {
                $extension = "jpg";
                $root = $GLOBALS['fileWEB'];
                $path = "gallery/".LngPath().Date("Y")."/".Date("m")."/".Date("d")."/";
                DeleteAllFilesInFolder($GLOBALS['fileWEB']."cache/".$path);
                @rmdir($GLOBALS['fileWEB']."cache/".$path);
                if(is_dir($root.$path) || mkdir($root.$path,0775,true)) {
                    $source = galleryGetImageFromBASE64($vals['ImageData'],$vals['ImageOrientation'],$imageWidth,$imageHeight);
                    if(IsSet($data)) { UnSet($data); }
                    $data['AlbumID'] = $vals['AlbumID'];
                    $data['Path'] = $path;
                    $data['Extension'] = $extension;
                    $data['ImageWidth'] = $imageWidth;
                    $data['ImageHeight'] = $imageHeight;
                    $data['Published'] = Time();
                    $data['CreatedByUserID'] = GetUserAccountID();
                    if(($arr['ImageID'] = $DB->Insert("GalleryImages",$data,$response)) !== false) {
                        if(@file_exists($root.$path.$arr['ImageID'].".".$extension)) { DeleteFile($root.$path.$arr['ImageID'].".".$extension); }
                        $fullpath = $root.$path.$arr['ImageID'].".".$extension;
                        $imageSave = imagejpeg($source,$fullpath,85);
                        imagedestroy($source);
                        return true;}
                    else {
                        $arr['Response'] = "Obrázek se nepodařilo uložit do databáze!";}}
                else {
                    $arr['Response'] = "Adresář ".XSS($root.$path)." se nepodařilo vytvořit!";}}
            else {
                $arr['Response'] = "Album neexistuje!";}}
        else {
            $arr['Response'] = Lng('InputValuesError');}}
    else {
        $arr['Response'] = Lng('UserIsNotLoggedIn');}
    return false;}
function galleryWriteAlbumAsPresentation($album_id) {
    global $MTPS;
    $image_height = 450;
    $str = "";
    $str.= "<div class=\"galleryAlbumAsPresentation\">";
    $album = WEB_Gallery_LoadAlbum($album_id);
    if($album === false) { return ""; }
    $images = WEB_Gallery_LoadListOfImages($album->ID,$images_count);
    $str.= "<h1>".$album->Title."</h1>";
    if($images_count > 0) {
        $images_count = 2;
        for($bb=0; $bb<$images_count; $bb++) {
            $src = $GLOBALS['urlWEB']."image/".$images[$bb]->ID."_h".$image_height.".".$images[$bb]->Extension;
            $st = "height: ".$image_height."px;";
            $str.= "<img src=\"".$src."\" class=\"gaapOnePage\" style=\"".$st."\" alt=\"".$images[$bb]->Title."\" />";}}
    $str.= "</div>";
    return $str;
}

function WEB_Gallery_WriteAlbum_StyleOdoprag_21($album_id,$show_title=true,$show_back=true) {
    global $MTPS;
    $image_height = 150;

    $str = "";
    $strC1 = "";
    $strD = "";
    $strC2 = "";

    $album = WEB_Gallery_LoadAlbum($album_id);
    if($album === false) { return ""; }
    $images = WEB_Gallery_LoadListOfImages($album->ID,$images_count);
    if($images_count > 0) {
        for($bb=0; $bb<$images_count; $bb++) {
            $title = $images[$bb]->Title."&#13;&#10;&#13;&#10;Klikni pro větší podrobný obrázek";

            if($bb == 0) {
                $src = $GLOBALS['urlWEB']."image/file/".$images[$bb]->Path.$images[$bb]->ID.".".$images[$bb]->Extension."?width=220";
//                $st = "width:220px;";
                $strD.= "<div class='gal21Detail'>";
                $strD.= "<a  onclick=\"galleryShowFullImage(".$images[$bb]->AlbumID.",".$images[$bb]->ID.");Stop();return false;\" target=\"_blank\" 
href=\"".$GLOBALS['urlWEB'].$images[$bb]->Path.$images[$bb]->ID.".".$images[$bb]->Extension."\" title=\"".$title."\" >";
                $strD.= "<img src=\"".$src."\" alt=\"".$title."\"/>";
//                style=\"".$st."\"
                $strD.= "</a>";
                $strD.="</div>";
//                $str.="<div class='galleryOneAlbumPreviewFlex'>";
            } else {
//                $src = $GLOBALS['urlWEB']."image/file/".$images[$bb]->Path.$images[$bb]->ID.".".$images[$bb]->Extension."?Width=220";
//                $st = "width:220px;";}
                $src = $GLOBALS['urlWEB'] . "image/file/" . $images[$bb]->Path . $images[$bb]->ID . "." . $images[$bb]->Extension . "?Square=40";
                $st = "width:40px;margin:0;padding:0";

                if($bb <= 4) {
                    $strC1 .= "<div class='gal21PreviewColumnImage' ><a   onclick=\"galleryShowFullImage(" . $images[$bb]->AlbumID . "," . $images[$bb]->ID . ");Stop();return false;\" target=\"_blank\" href=\"" . $GLOBALS['urlWEB'] . $images[$bb]->Path . $images[$bb]->ID . "." . $images[$bb]->Extension . "\" title=\"" . $title . "\">";
                    $strC1 .= "<img src=\"" . $src . "\"   alt=\"" . $images[$bb]->Title . "\" />";
                    $strC1 .= "</a></div>";
                } else {
                    $strC2 .= "<div class='gal21PreviewColumnImage' ><a  onclick=\"galleryShowFullImage(" . $images[$bb]->AlbumID . "," . $images[$bb]->ID . ");Stop();return false;\" target=\"_blank\" href=\"" . $GLOBALS['urlWEB'] . $images[$bb]->Path . $images[$bb]->ID . "." . $images[$bb]->Extension . "\" title=\"" . $title . "\">";
                    $strC2 .= "<img src=\"" . $src . "\"  alt=\"" . $images[$bb]->Title . "\" />";
                    $strC2 .= "</a></div>";
                }
            }
        }
//        $str.="</div>";
        $str="<div class='gal21'>";
        $str.="<div class='gal21PreviewColumn'>";
        $str.=$strC1;
        $str.="</div>";

        $str.=$strD;

        $str.="<div class='gal21PreviewColumn'>";
        $str.=$strC2;
        $str.="</div>";
//        $str.="</div>";


    } else {
        $str.= "<p>Album je prázdné.</p>";
    }
    $str.= "</div>";
    return $str;
}



function WEB_Gallery_WriteAlbum_StyleOdoprag_20($album_id,$show_title=true,$show_back=true) {
    global $MTPS;
    $image_height = 150;
    $str = "";
    $str.= "<div class='galleryOneAlbum'>";
    $album = WEB_Gallery_LoadAlbum($album_id);
    if($album === false) { return ""; }
    $images = WEB_Gallery_LoadListOfImages($album->ID,$images_count);
    if($images_count > 0) {
        for($bb=0; $bb<$images_count; $bb++) {
            $title = $images[$bb]->Title."&#13;&#10;&#13;&#10;Klikni pro větší podrobný obrázek";

            if($bb == 0) {
                $src = $GLOBALS['urlWEB']."image/file/".$images[$bb]->Path.$images[$bb]->ID.".".$images[$bb]->Extension."?width=220";
//                $st = "width:220px;";
                $str.= "<div class='galleryOneAlbumDetail'><a class=\"gallery_link\" onclick=\"galleryShowFullImage(".$images[$bb]->AlbumID.",".$images[$bb]->ID.");Stop();return false;\" target=\"_blank\" 
href=\"".$GLOBALS['urlWEB'].$images[$bb]->Path.$images[$bb]->ID.".".$images[$bb]->Extension."\" title=\"".$title."\" >";
                $str.= "<img src=\"".$src."\" class=\"gallery_img\"   alt=\"".$title."\"/>";
//                style=\"".$st."\"
                $str.= "</a>";
                $str.="</div>";
                $str.="<div class='galleryOneAlbumPreview'>";
                $str.="<div class='galleryOneAlbumPreviewFlex'>";
            } else {
//                $src = $GLOBALS['urlWEB']."image/file/".$images[$bb]->Path.$images[$bb]->ID.".".$images[$bb]->Extension."?Width=220";
//                $st = "width:220px;";}

                $src = $GLOBALS['urlWEB']."image/file/".$images[$bb]->Path.$images[$bb]->ID.".".$images[$bb]->Extension."?Square=40";
                $st = "width:40px;margin:0;padding:0";
                $str.= "<div class='galleryOneAlbumPreviewFlexItem' ><a class=\"gallery_link\"  onclick=\"galleryShowFullImage(".$images[$bb]->AlbumID.",".$images[$bb]->ID.");Stop();return false;\" target=\"_blank\" href=\"".$GLOBALS['urlWEB'].$images[$bb]->Path.$images[$bb]->ID.".".$images[$bb]->Extension."\" title=\"".$title."\">";
                $str.= "<img src=\"".$src."\" class=\"gallery_img_preview\" style=\"".$st."\" alt=\"".$images[$bb]->Title."\" />";
                $str.= "</a></div>";
            }
        }
        $str.="</div>";
        $str.="</div>";
    } else {
        $str.= "<p>Album je prázdné.</p>";
    }
    $str.= "</div>";
    return $str;
}

function WEB_Gallery_WriteAlbum_StyleOdoprag($album_id,$show_title=true,$show_back=true) {
    global $MTPS;
    $image_height = 150;
    $str = "";
    $str.= "<div class=\"galleryOneAlbum\">";
    $album = WEB_Gallery_LoadAlbum($album_id);
    if($album === false) { return ""; }
    $images = WEB_Gallery_LoadListOfImages($album->ID,$images_count);
    if($images_count > 0) {
        for($bb=0; $bb<$images_count; $bb++) {
            if($bb == 0) {
                $src = $GLOBALS['urlWEB']."image/file/".$images[$bb]->Path.$images[$bb]->ID.".".$images[$bb]->Extension."?Width=220";
                $st = "width:220px;";}
            else {
                $src = $GLOBALS['urlWEB']."image/file/".$images[$bb]->Path.$images[$bb]->ID.".".$images[$bb]->Extension."?Square=70";
                $st = "width:70px;margin:0;padding:0";}
            $str.= "<a class=\"gallery_link\" style=\"margin:0 4px 0 0;padding:0\" onclick=\"galleryShowFullImage(".$images[$bb]->AlbumID.",".$images[$bb]->ID.");Stop();return false;\" target=\"_blank\" href=\"".$GLOBALS['urlWEB'].$images[$bb]->Path.$images[$bb]->ID.".".$images[$bb]->Extension."\" title=\"".$images[$bb]->Title."\">";
            $str.= "<img src=\"".$src."\" class=\"gallery_img\" style=\"".$st."\" alt=\"".$images[$bb]->Title."\" />";
            $str.= "</a>";}}
    else {
        $str.= "<p>Album je prázdné.</p>";}
    $str.= "</div>";
    return $str;
}

if(defined("user")) {
    function WEB_LoadUserJS($client_layout) {
        
        global $Web, $MTPS;
        $js = "";
        $js.= trm("");
        $js.= trm("function UsernameChange() {");
        $js.= trm(" setTimeout(function(){UserLoginTestUsername(document.getElementById('UserLoginUsername').value);},2000);");
        $js.= trm("}");
        $js.= trm("");
        $js.= trm("function UserLoginTestUsername(username) {");
        $js.= trm(" var params = '&AjaxReq=UserLogin.TestUsername';");
        $js.= trm(" params+= '&Username='+encodeURIComponent(username);");
        $js.= trm(" AsynchronousPOST(params,function(post){");
        $js.= trm(" try { var json = JSON.parse(post); } catch(e) { console.log(post); return false; }");
        $js.= trm(" if(json.Status != 1) { SetInner('AjaxReport',''); return false; }");
        $js.= trm(" SetInner('AjaxReport',''); ");
        $js.= trm(" });");
        $js.= trm(" return true;");
        $js.= trm("}");
        $js.= trm("");
        $js.= trm("function UserLoginDoLogin() {");
        $js.= trm(" var params = '&AjaxReq=UserLogin';");
        $js.= trm(" params+= '&LoginEmail='+encodeURIComponent(document.getElementById('UserLoginUsername').value);");
        $js.= trm(" params+= '&LoginPassword='+encodeURIComponent(document.getElementById('UserLoginPassword').value);");
        $js.= trm(" params+= '&RememberLogin='+encodeURIComponent(document.getElementById('UserLoginRememberLogin').checked);");
        $js.= trm(" if(typeof document.getElementById('GoFrom') != 'undefined' && document.getElementById('GoFrom').value.length > 0) { params+= '&GoFrom='+encodeURIComponent(document.getElementById('GoFrom').value); }");
        $js.= trm(" if(typeof document.getElementById('GoTo') != 'undefined' && document.getElementById('GoTo').value.length > 0) { params+= '&GoTo='+encodeURIComponent(document.getElementById('GoTo').value); }");
        $js.= trm(" var post = SynchronousPOST(params);");
        $js.= trm(" try { var json = JSON.parse(post); } catch(e) { console.log(post); return false; }");
        $js.= trm(" if(json.Status != 1) { SetInner('AjaxReport','<div class=\"ErrorReport\">'+json.Response+'</div>'); return false; }");
        $js.= trm(" SetInner('AjaxReport','<div class=\"SuccessReport\">Přihlášení proběhlo úspěšně.</div>');");
        $js.= trm(" window.location.href = json.ReloadToURL;");
        $js.= trm(" return true;");
        $js.= trm("}");
        $js.= trm("");
        if($client_layout <= 2) {
            $js.= trm("var g_mnuFirstOpen = 0;");
            $js.= trm("var g_mnuLastID = '';");
            $js.= trm("");
            $js.= trm("function Load() {");
            $js.= trm(" UpdateWebHeight();");
            $js.= trm(" if(!TestAttribute('input','autofocus')) { document.getElementById('UserLoginUsername').focus(); }");
            $js.= trm("}");
            $js.= trm("function UpdateWebHeight() {");
            $js.= trm(" var windowHeight = 0;");
            $js.= trm(" if(typeof(window.innerHeight)=='number') {");
            $js.= trm(" windowHeight = window.innerHeight;");
            $js.= trm(" }");
            $js.= trm(" else {");
            $js.= trm(" if(document.documentElement && document.documentElement.clientHeight) {");
            $js.= trm(" windowHeight = document.documentElement.clientHeight;");
            $js.= trm(" }");
            $js.= trm(" else {");
            $js.= trm(" if(document.body && document.body.clientHeight) {");
            $js.= trm(" windowHeight = document.body.clientHeight;");
            $js.= trm(" }");
            $js.= trm(" }");
            $js.= trm(" }");
            $js.= trm(" header_height = document.getElementById(\"Header\").offsetHeight;");
            $js.= trm(" footer_height = document.getElementById(\"Footer\").offsetHeight;");
            $js.= trm(" content_height = windowHeight - header_height - footer_height;");
            $js.= trm(" document.getElementById(\"Web\").style.height = content_height + \"px\";");
            $js.= trm(" login_height = document.getElementById(\"Login2\").offsetHeight;");
            $js.= trm(" login_margin = content_height/2 - login_height/2;");
            $js.= trm(" login_margin = login_margin;");
            $js.= trm(" if(login_margin < 0) { login_margin = 0; }");
            $js.= trm(" document.getElementById(\"Login\").style.paddingTop = login_margin + \"px\";");
            $js.= trm(" return windowHeight;");
            $js.= trm("}");}
        if($client_layout == 3) {
            $js.= trm("");
            $js.= trm("function BodyLoad(client_layout) {");
            $js.= trm(" BodyResize();");
            $js.= trm("}");
            $js.= trm("function SetInputDisplay(elem,display,width) {");
            $js.= trm(" if(ElemExists(elem)) {");
            $js.= trm(" SetDisplay('label'+elem,display);");
            $js.= trm(" SetDisplay(elem,display);");
            $js.= trm(" SetWidth('label'+elem,width);");
            $js.= trm(" }");
            $js.= trm("}");
            $js.= trm("function BodyResize(client_layout) {");
            $js.= trm(" var w = GetWindowWidth();");
            $js.= trm(" var h = GetWindowHeight();");
            $js.= trm(" var main_dim = h;");
            $js.= trm(" var body_width = '90%';");
            $js.= trm(" var landscape = true;");
            $js.= trm(" if(h > w) { landscape = false; main_dim = w; }");
            $js.= trm(" if(landscape) { body_width = '70%'; }");
            $js.= trm(" var font_size = Math.round((13*main_dim)/300);");
            $js.= trm(" if(font_size < 8) { font_size = 8; }");
            $js.= trm(" SetBodyFontSize(font_size+'px');");
            $js.= trm(" SetSize('Overlay',w+'px',h+'px');");
            $js.= trm(" ResizeMobileMenu();");
            $js.= trm(" ");
            $js.= trm(" if(ElemExists('formUserLogin')) {");
            $js.= trm(" if(landscape) {");
            $js.= trm(" SetFontSize('labelUserLoginUsername','100%');");
            $js.= trm(" SetFontSize('labelUserLoginPassword','100%');");
            $js.= trm(" SetInputDisplay('UserLoginUsername','inline-block','auto');");
            $js.= trm(" SetInputDisplay('UserLoginPassword','inline-block','auto');");
            $js.= trm(" var label_width = Math.max(GetWidth('labelUserLoginUsername'),GetWidth('labelUserLoginPassword'));");
            $js.= trm(" var input_width = GetWidth('UserLoginUsername');");
            $js.= trm(" label_width+= font_size;");
            $js.= trm(" SetInputDisplay('UserLoginUsername','inline-block',label_width+'px');");
            $js.= trm(" SetInputDisplay('UserLoginPassword','inline-block',label_width+'px');");
            $js.= trm(" SetPadding('labelUserLoginRememberLogin','.3em 0 .3em '+label_width+'px');");
            $js.= trm(" body_width = (label_width+input_width)+'px';");
            $js.= trm(" }");
            $js.= trm(" else {");
            $js.= trm(" SetFontSize('labelUserLoginUsername','70%');");
            $js.= trm(" SetFontSize('labelUserLoginPassword','70%');");
            $js.= trm(" SetInputDisplay('UserLoginUsername','block','auto');");
            $js.= trm(" SetInputDisplay('UserLoginPassword','block','auto');");
            $js.= trm(" SetPadding('labelUserLoginRememberLogin','.3em 0 .3em 0');");
            $js.= trm(" body_width = GetWidth('UserLoginUsername')+'px';");
            $js.= trm(" }");
            $js.= trm(" }");
            $js.= trm(" ");
            $js.= trm(" if(ElemExists('formForgottenPassword')) {");
            $js.= trm(" if(landscape) {");
            $js.= trm(" SetFontSize('labelUsernameOrEmail','100%');");
            $js.= trm(" SetInputDisplay('UsernameOrEmail','inline-block','auto');");
            $js.= trm(" var label_width = GetWidth('labelUsernameOrEmail');");
            $js.= trm(" var input_width = GetWidth('UsernameOrEmail');");
            $js.= trm(" label_width+= font_size;");
            $js.= trm(" SetWidth('labelUsernameOrEmail',label_width+'px');");
            $js.= trm(" body_width = (label_width+input_width)+'px';");
            $js.= trm(" }");
            $js.= trm(" else {");
            $js.= trm(" SetFontSize('labelUsernameOrEmail','70%');");
            $js.= trm(" SetInputDisplay('UsernameOrEmail','block','auto');");
            $js.= trm(" body_width = GetWidth('UsernameOrEmail')+'px';");
            $js.= trm(" }");
            $js.= trm(" }");
            $js.= trm(" ");
            $js.= trm(" if(ElemExists('formNewPassword')) {");
            $js.= trm(" if(landscape) {");
            $js.= trm(" SetFontSize('labelRequestHash','100%');");
            $js.= trm(" SetFontSize('labelNewPassword','100%');");
            $js.= trm(" SetFontSize('labelNewPasswordAgain','100%');");
            $js.= trm(" SetInputDisplay('RequestHash','inline-block','auto');");
            $js.= trm(" SetInputDisplay('NewPassword','inline-block','auto');");
            $js.= trm(" SetInputDisplay('NewPasswordAgain','inline-block','auto');");
            $js.= trm(" var label_width = Math.max(GetWidth('labelRequestHash'),GetWidth('labelNewPassword'),GetWidth('labelNewPasswordAgain'));");
            $js.= trm(" var input_width = GetWidth('RequestHash');");
            $js.= trm(" label_width+= font_size;");
            $js.= trm(" SetInputDisplay('RequestHash','inline-block',label_width+'px');");
            $js.= trm(" SetInputDisplay('NewPassword','inline-block',label_width+'px');");
            $js.= trm(" SetInputDisplay('NewPasswordAgain','inline-block',label_width+'px');");
            $js.= trm(" body_width = (label_width+input_width)+'px';");
            $js.= trm(" }");
            $js.= trm(" else {");
            $js.= trm(" SetFontSize('labelRequestHash','70%');");
            $js.= trm(" SetFontSize('labelNewPassword','70%');");
            $js.= trm(" SetFontSize('labelNewPasswordAgain','70%');");
            $js.= trm(" SetInputDisplay('RequestHash','block','auto');");
            $js.= trm(" SetInputDisplay('NewPassword','block','auto');");
            $js.= trm(" SetInputDisplay('NewPasswordAgain','block','auto');");
            $js.= trm(" body_width = GetWidth('RequestHash')+'px';");
            $js.= trm(" }");
            $js.= trm(" }");
            $js.= trm(" ");
            $js.= trm(" if(ElemExists('formChangePassword')) {");
            $js.= trm(" if(landscape) {");
            $js.= trm(" SetFontSize('labelOldPassword','100%');");
            $js.= trm(" SetFontSize('labelNewPassword','100%');");
            $js.= trm(" SetFontSize('labelNewPasswordAgain','100%');");
            $js.= trm(" SetInputDisplay('OldPassword','inline-block','auto');");
            $js.= trm(" SetInputDisplay('NewPassword','inline-block','auto');");
            $js.= trm(" SetInputDisplay('NewPasswordAgain','inline-block','auto');");
            $js.= trm(" var label_width = Math.max(GetWidth('labelOldPassword'),GetWidth('labelNewPassword'),GetWidth('labelNewPasswordAgain'));");
            $js.= trm(" var input_width = GetWidth('OldPassword');");
            $js.= trm(" label_width+= font_size;");
            $js.= trm(" SetInputDisplay('OldPassword','inline-block',label_width+'px');");
            $js.= trm(" SetInputDisplay('NewPassword','inline-block',label_width+'px');");
            $js.= trm(" SetInputDisplay('NewPasswordAgain','inline-block',label_width+'px');");
            $js.= trm(" body_width = (label_width+input_width)+'px';");
            $js.= trm(" }");
            $js.= trm(" else {");
            $js.= trm(" SetFontSize('labelOldPassword','70%');");
            $js.= trm(" SetFontSize('labelNewPassword','70%');");
            $js.= trm(" SetFontSize('labelNewPasswordAgain','70%');");
            $js.= trm(" SetInputDisplay('OldPassword','block','auto');");
            $js.= trm(" SetInputDisplay('NewPassword','block','auto');");
            $js.= trm(" SetInputDisplay('NewPasswordAgain','block','auto');");
            $js.= trm(" body_width = GetWidth('OldPassword')+'px';");
            $js.= trm(" }");
            $js.= trm(" }");
            $js.= trm(" ");
            $js.= trm(" if(ElemExists('formNewUser')) {");
            $js.= trm(" if(landscape) {");
            $js.= trm(" SetFontSize('labelNewUserUsername','100%');");
            $js.= trm(" SetInputDisplay('NewUserUsername','inline-block','auto');");
            $js.= trm(" SetFontSize('labelNewUserEmail','100%');");
            $js.= trm(" SetInputDisplay('NewUserEmail','inline-block','auto');");
            $js.= trm(" SetFontSize('labelNewUserPassword1','100%');");
            $js.= trm(" SetInputDisplay('NewUserPassword1','inline-block','auto');");
            $js.= trm(" SetFontSize('labelNewUserPassword2','100%');");
            $js.= trm(" SetInputDisplay('NewUserPassword2','inline-block','auto');");
            $js.= trm(" var label_width = Math.max(GetWidth('labelNewUserUsername'),GetWidth('labelNewUserEmail'),GetWidth('labelNewUserPassword1'),GetWidth('labelNewUserPassword2'));");
            $js.= trm(" var input_width = GetWidth('NewUserUsername');");
            $js.= trm(" label_width+= font_size;");
            $js.= trm(" SetWidth('labelNewUserUsername',label_width+'px');");
            $js.= trm(" SetWidth('labelNewUserEmail',label_width+'px');");
            $js.= trm(" SetWidth('labelNewUserPassword1',label_width+'px');");
            $js.= trm(" SetWidth('labelNewUserPassword2',label_width+'px');");
            $js.= trm(" body_width = (label_width+input_width)+'px';");
            $js.= trm(" }");
            $js.= trm(" else {");
            $js.= trm(" SetFontSize('labelNewUserUsername','70%');");
            $js.= trm(" SetInputDisplay('NewUserUsername','block','auto');");
            $js.= trm(" SetFontSize('labelNewUserEmail','70%');");
            $js.= trm(" SetInputDisplay('NewUserEmail','block','auto');");
            $js.= trm(" SetFontSize('labelNewUserPassword1','70%');");
            $js.= trm(" SetInputDisplay('NewUserPassword1','block','auto');");
            $js.= trm(" SetFontSize('labelNewUserPassword2','70%');");
            $js.= trm(" SetInputDisplay('NewUserPassword2','block','auto');");
            $js.= trm(" body_width = GetWidth('NewUserUsername')+'px';");
            $js.= trm(" }");
            $js.= trm(" }");
            $js.= trm(" ");
            $js.= trm(" document.getElementsByTagName('body')[0].style.width = body_width;");
            $js.= trm(" var desk_margin = h/2 - GetHeight('Desk')/2 - 20;");
            $js.= trm(" if(desk_margin < 0) { desk_margin = 0; }");
            $js.= trm(" SetMarginTop('Desk',desk_margin+'px')");
            $js.= trm("}");}
        return $js;}
    function WEB_LoadUserCSS($client_layout) {
        global $Web, $MTPS;
        $css = "";
        if($client_layout <= 2) {
            $cl = "white";
            $bg = "rgb(0,102,153)";
            $min_width = "680px";
            $max_width = "980px";
            $header_font_size = "25px";
            $footer_font_size = "22px";
            $web_width = "315px";
            $css.= trm("*:focus { outline: none; }");
            $css.= trm("body { overflow: hidden; margin: 0 auto; padding: 0; font-family: Calibri,Arial,sans-serif; color: black; font-size: 14px; }");
            $css.= trm("img { margin: 0; padding: 0; border: 0; }");
            $css.= trm(".clear {clear: both;margin: 0;padding: 0;width: auto;}");
            $css.= trm("");
            $css.= trm("#mnuFirst { margin: 0; padding: 0; border-radius: 2px; box-shadow: black 2px 2px 10px; display: none; position: absolute; left: 0; top: 0; text-align: left; background: rgb(250,250,250); white-space: nowrap; border: 1px solid rgb(240,240,240);}");
            $css.= trm("#mnuFirst .inner { margin: 0; padding: 7px; border-radius: 0; box-shadow: 0; border: 0;}");
            $css.= trm("#mnuFirst img {margin: 0 7px 0 0; padding: 0; border: 0;vertical-align: center;}");
            $css.= trm("#mnuFirst p {margin: 0; padding: 10px 0 0 0; border: 0; color: black; white-space: nowrap;}");
            $css.= trm("#mnuFirst a {display: block; margin: 0; padding: 5px 10px 5px 10px; border: 1px solid transparent; white-space: nowrap; color: black; text-decoration: none; }");
            $css.= trm("#mnuFirst a:hover {border: 1px solid rgb(0,102,153); background: rgb(51,153,255); color: white; }");
            $css.= trm(".Report { display: block; border: 1px solid blue; background: aqua; margin: 0 0 7px 0; padding: 7px; font-size: 90%; font-weight: normal; color: black; border-radius: 5px; }");
            $css.= trm(".Report h7 { display: block; font-weight: bold; font-size: 110%; }");
            $css.= trm(".ErrorReport { display: block; border: 1px solid maroon; background: rgba(255,0,0,.7); margin: 0 0 7px 0; padding: 7px; font-size: 90%; font-weight: normal; color: white; border-radius: 5px; }");
            $css.= trm(".ErrorReport h7 { display: block; font-weight: bold; font-size: 110%; }");
            $css.= trm(".SuccessReport { display: block; border: 1px solid lime; background: green; margin: 0 0 7px 0; padding: 7px; font-size: 90%; font-weight: normal; color: white; border-radius: 5px; }");
            $css.= trm(".SuccessReport h7 { display: block; font-weight: bold; font-size: 110%; }");
            $css.= trm("#Background { overflow: hidden; padding: 0; background: $bg; }");
            $css.= trm("#Desk { overflow: hidden; margin-left: auto; margin-right: auto; padding: 0; width: auto; min-width: $min_width; max-width: $max_width; }");
            $css.= trm("#Header { margin: 0 auto; padding: 0; font-size: $header_font_size; color: white; padding: 1em 1em 0 1em; }");
            $css.= trm("#Header a { color: white; text-decoration: none; }");
            $css.= trm("#Header a:hover { text-decoration: underline; }");
            $css.= trm("#Header .Left {");
            $css.= trm("float: left;");
            $css.= trm("width: 70%; ");
            $css.= trm("}");
            $css.= trm("#Header .Right {");
            $css.= trm("text-align: right; ");
            $css.= trm("margin: 0 0 0 70%;");
            $css.= trm("}");
            $css.= trm("#Header .Right img {");
            $css.= trm("vertical-align: baseline;");
            $css.= trm("margin: 0 0 0 0;");
            $css.= trm("padding: 0 10px 0 0;");
            $css.= trm("}");
            $css.= trm("#Header .Right .Arrow {");
            $css.= trm("vertical-align: baseline;");
            $css.= trm("margin: 0 0 0 0;");
            $css.= trm("padding: 0 0 0 6px;");
            $css.= trm("}");
            $css.= trm("#Header .Right a {");
            $css.= trm("margin: 0;");
            $css.= trm("padding: 0;");
            $css.= trm("color: white;");
            $css.= trm("text-decoration: none;");
            $css.= trm("}");
            $css.= trm("#Header .Right a:hover {");
            $css.= trm("text-decoration: underline;");
            $css.= trm("}");
            $css.= trm("#Footer { margin: 0 auto; padding: 0; font-size: $footer_font_size; color: white; padding: 0 1em 1em 1em; }");
            $css.= trm("#Footer a { color: white; text-decoration: none; }");
            $css.= trm("#Footer a:hover { text-decoration: underline; }");
            $css.= trm("#Footer .Right {");
            $css.= trm("float: right;");
            $css.= trm("width: 13.5em; text-align: right; white-space: nowrap;");
            $css.= trm("}");
            $css.= trm("#Footer .Left {");
            $css.= trm("margin: 0 13.5em 0 0;");
            $css.= trm("}");
            $css.= trm("#Web { overflow: auto; margin-left: auto; margin-right: auto; padding: 0; width: $web_width; }");
            $css.= trm("#Login { color: $cl; margin: 0 auto; padding: 0; }");
            $css.= trm("#Login2 { background: rgba(45,45,45,.3); padding: 25px; border-radius: 15px; border: 1px solid rgba(255,255,255,.3); }");
            $css.= trm("h1 { margin: 0; padding: 0 0 0 0; display: block; font-size: 150%; font-weight: bold; overflow: hidden; white-space: nowrap; }");
            $css.= trm("h2 { margin: 0; padding: 0 0 .5em 0; display: block; font-size: 75%; font-weight: normal; overflow: hidden; white-space: nowrap; }");
            $css.= trm("a { color: white; text-decoration: underline; }");
            $css.= trm("a:hover { color: white; text-decoration: none; }");
            $css.= trm("form h1 { margin: 0 0 10px 0; padding: 0; display: block; color: white; font-size: 30px; }");
            $css.= trm("form h2 { display: none; }");
            $css.= trm("form div { margin: 0; padding: .3em 0 0 0; }");
            $css.= trm("form label { margin: 0 0 3px 0; display: block; color: white; }");
            $css.= trm("form .Checkbox { margin: 0; padding: 0; display: block; }");
            $css.= trm("form .Checkbox span { margin: 0; padding: 0 0 0 3px; display: inline-block; color: white; font-size: 120%; }");
            $css.= trm("form span { display: block; }");
            $css.= trm("form .Submit { text-align: right; margin: 0; padding: 10px 0 3px 0; display: block; }");
            $css.= trm("form .info { margin: 0; padding: 0 0 15px 0; display: block; color: white; }");
            $css.= trm("form a { margin: 0; padding: 0; color: white; text-decoration: underline; }");
            $css.= trm("form a:hover { text-decoration: none; }");
            $css.= trm("form input[type=text] { margin: 0 0 15px 0; padding: 2px; font-size: 20px; width: 257px; border: 1px solid gray; border-radius: 3px; }");
            $css.= trm("form input[type=email] { margin: 0 0 15px 0; padding: 2px; font-size: 20px; width: 257px; border: 1px solid gray; border-radius: 3px; }");
            $css.= trm("form input[type=password] { margin: 0 0 5px 0; padding: 2px; font-size: 20px; width: 257px; border: 1px solid gray; border-radius: 3px; }");
            $css.= trm("form input[type=submit] { margin: 0; padding: 3px 20px 3px 20px; font-size: 16px; font-weight: bold; }");
            $css.= trm(".bottom { padding: .5em 0 0 0; text-align: right; }");}
        if($client_layout == 3) {
            $width = "90%";
            $bg = "rgb(0,102,153)";
            $bghi = "rgb(51,153,255)";
            $cl = "white";
            $css.= trm("*:focus { outline: none; }");
            $css.= trm("body { margin: 0; margin-left: auto; margin-right: auto; padding: 0; width: $width; font-family: Calibri,Arial,sans-serif; font-size: 14px; background: $bg; color: $cl; }");
            $css.= trm("img { margin: 0; padding: 0; border: 0; }");
            $css.= trm(".clear { clear: both; margin: 0; padding: 0; width: auto;}");
            $css.= trm("");
            $css.= trm("#Overlay { visibility: hidden; z-index: 5000; position: absolute; left: 0; top: 0; overflow: hidden; margin: 0; padding: 0; background: rgb(50,50,50); background: rgba(0,0,0,.8); }");
            $css.= trm("#mnuMobile { position: absolute; font-size: 180%; width: auto; height: auto; margin: 0; padding: 0; color: black; background: rgb(255,255,255); overflow: auto; }");
            $css.= trm("#mnuMobile .inner { margin: 0; padding: 1em; border-radius: 0; box-shadow: 0; border: 0; }");
            $css.= trm("#mnuMobile img { margin: 0 .5em 0 .2em; padding: 0; border: 0; width: .9em; vertical-align: center;}");
            $css.= trm("#mnuMobile a { display: block; margin: 0; padding: .3em .1em .3em .1em; border: 1px solid transparent; white-space: nowrap; color: black; text-decoration: none; }");
            $css.= trm("#mnuMobile a:hover { border: 1px solid rgb(0,102,153); background: rgb(51,153,255); color: white; }");
            $fs = "60%";
            $fsh = "110%";
            $pd = ".3em";
            $css.= trm(".Report { display: block; border: 1px solid blue; background: aqua; margin: 0; padding: $pd; font-size: $fs; font-weight: normal; color: black; border-radius: 5px; }");
            $css.= trm(".Report h7 { display: block; font-weight: bold; font-size: $fsh; }");
            $css.= trm(".ErrorReport { display: block; border: 1px solid maroon; background: rgba(255,0,0,.7); margin: 0; padding: $pd; font-size: $fs; font-weight: normal; color: white; border-radius: 5px; }");
            $css.= trm(".ErrorReport h7 { display: block; font-weight: bold; font-size: $fsh; }");
            $css.= trm(".SuccessReport { display: block; border: 1px solid lime; background: green; margin: 0; padding: $pd; font-size: $fs; font-weight: normal; color: white; border-radius: 5px; }");
            $css.= trm(".SuccessReport h7 { display: block; font-weight: bold; font-size: $fsh; }");
            $css.= trm("#Desk { margin: 0; padding: 0; }");
            $css.= trm("h1 { margin: 0; padding: 0 0 0 0; display: block; font-size: 150%; font-weight: bold; overflow: hidden; white-space: nowrap; }");
            $css.= trm("h2 { margin: 0; padding: 0 0 .5em 0; display: block; font-size: 75%; font-weight: normal; overflow: hidden; white-space: nowrap; }");
            $css.= trm("a { color: white; text-decoration: underline; }");
            $css.= trm("a:hover { color: white; text-decoration: none; }");
            $css.= trm("#Title { clear: bmargin: 0; padding: 0; }");
            $css.= trm("#Title .left {");
            $css.= trm(" margin: 0 18% 0 0; ");
            $css.= trm(" padding: 0; ");
            $css.= trm(" width: 82%; ");
            $css.= trm(" text-align: left; ");
            $css.= trm("}");
            $css.= trm("#Title .right {");
            $css.= trm(" margin: 0;");
            $css.= trm(" padding: 0; ");
            $css.= trm(" float: right;");
            $css.= trm(" width: 18%; ");
            $css.= trm(" text-align: right; ");
            $css.= trm("}");
            $css.= trm("#Title a { color: $cl; display: inline-block; margin: 0; padding: 0 0 .1em 0; font-size: 150%; }");
            $css.= trm("#Title a:hover { color: $cl; background: $bghi; }");
            $css.= trm("#Title .down { color: $cl; background: $bghi; }");
            $css.= trm("#Title .flag {");
            $css.= trm("height: .6em; ");
            $css.= trm("padding: 0 0 .0 .3em; ");
            $css.= trm("}");
            $css.= trm("#Title .arrow {");
            $css.= trm("height: .5em; ");
            $css.= trm("padding: 0 .3em 0 .25em; ");
            $css.= trm("}");
            $css.= trm("form { margin: 0; padding: 0; display: block; }");
            $css.= trm("form a { margin: 0; padding: .3em 0 0 0; color: $cl; text-decoration: underline; }");
            $css.= trm("form a:hover { text-decoration: none; }");
            $css.= trm("form h1 { margin: 0; padding: 0 0 0 0; display: block; font-size: 150%; font-weight: normal; overflow: hidden; white-space: nowrap; }");
            $css.= trm("form h2 { margin: 0; padding: 0 0 .5em 0; display: block; font-size: 75%; font-weight: normal; overflow: hidden; white-space: nowrap; }");
            $css.= trm("form div { margin: 0; padding: .5em 0 0 0; overflow: hidden; white-space: nowrap; }");
            $css.= trm("form span { margin: 0; padding: 0; overflow: hidden; white-space: nowrap; }");
            $css.= trm("form label { margin: 0; padding: 0; display: block; overflow: hidden; white-space: nowrap; }");
            $css.= trm("form .bottom { text-align: right; }");
            $css.= trm("form .info { margin: .5em 0 .5em 0; padding: 0; overflow: normal; white-space: normal; font-size: 90%; display: block; }");
            $fs = "100%";
            $w = "16em";
            $clb = "gray";
            $css.= trm("form input[type=text] { margin: 0; padding: .3em; font-size: $fs; display: block; width: $w; border-radius: .3em; border: 1px solid $clb; }");
            $css.= trm("form input[type=email] { margin: 0; padding: .3em; font-size: $fs; display: block; width: $w; border-radius: .3em; border: 1px solid $clb; }");
            $css.= trm("form input[type=password] { margin: 0; padding: .3em; font-size: $fs; display: block; width: $w; border-radius: .3em; border: 1px solid $clb; }");
            $css.= trm("form input[type=submit] { margin: .3em 0 .2em 0; padding: .57em 1.5em .5em 1.5em; font-size: 110%; font-weight: bold; }");
            $css.= trm("");}
        return $css;}
    function WEB_LoadUserLayout($client_layout) {
        global $Web, $MTPS;
        $layout = "";
//        error_log("WEB_LoadUserLayout ");

        if($client_layout <= 2) {
            $layout.= trm("<!doctype html>");
            $layout.= trm("<head lang=\"<PagePart:Language:>\">");
            $layout.= trm("<meta http-equiv=\"content-type\" content=\"text/html; charset=<PagePart:Charset:>\" />");
            if(IsSet($MTPS->Favicon) && $MTPS->Favicon != "") { $layout.= trm("<link rel=\"shortcut icon\" type=\"image/x-icon\" href=\"".$MTPS->Favicon."\" />"); }
            $layout.= trm("<link rel=\"stylesheet\" type=\"text/css\" href=\"".$GLOBALS['urlCSS']."mtps<PagePart:MTPSReleaseTime:>.css\" />");
            $layout.= trm("<link rel=\"stylesheet\" type=\"text/css\" href=\"".$GLOBALS['urlCSS']."user<PagePart:MTPSReleaseTime:>.css\" />");
            $layout.= trm("<script src=\"<PagePart:urlJS:>mtps<PagePart:MTPSReleaseTime:>.js\"></script>");
            $layout.= trm("<script src=\"<PagePart:urlJS:>dialogs<PagePart:MTPSReleaseTime:>.js\"></script>");
            $layout.= trm("<script src=\"".$GLOBALS['urlJS']."user<PagePart:MTPSReleaseTime:>.js?url=".urlencode($MTPS->URL)."\"></script>");
            $layout.= trm("<title><PagePart:Title:></title>");
            $layout.= trm("</head>");
            $Web->OnLoad = "Load();";
            $Web->OnResize = "UpdateWebHeight();";
            $Web->OnMouseUp = "BodyMouseUp();";
            if($Web->OnLoad != "") { $onload = " onload=\"mtpsLoadPageImages();".$Web->OnLoad."\""; } else { $onload = " onload=\"mtpsLoadPageImages();\""; }
            if($Web->OnResize != "") { $onresize = " onresize=\"".$Web->OnResize."\""; } else { $onresize = ""; }
            if($Web->OnMouseUp != "") { $onmouseup = " onmouseup=\"".$Web->OnMouseUp."\""; } else { $onmouseup = ""; }
            $layout.= trm("<body lang=\"<PagePart:Language:>\"$onload$onmouseup$onresize>");
            $layout.= trm("<div id=\"Background\">");
            $layout.= trm("<div id=\"Desk\">");
            $layout.= trm("<div id=\"Header\">");
            $layout.= trm("<div class=\"Left\"><a href=\"".$GLOBALS['urlWEB']."\">".$MTPS->WebName."</a></div>");
            if(IsSet($data)) { UnSet($data); }
            $data['ID'] = "btnLanguage";
            $data['OnClick'] = "OpenFirstMenu(".$MTPS->ClientLayout.",'btnLanguage');";
            $layout.= trm("<div class=\"Right\">".SmartLinkEx("<img src=\"<PagePart:urlMTPS:>img/flag/flag-".$MTPS->Language."-h16.png\" alt=\"\" />".Lng('LanguageName')."<img src=\"<PagePart:urlMTPS:>img/triarrow-down-white-7x11.png\" class=\"Arrow\" alt=\"\" />",$MTPS->URL,$data)."</div>");
            $layout.= trm("</div>");
            $layout.= trm("<div class=\"clear\"></div>");
            $layout.= trm("<div id=\"Web\">");
            $layout.= trm("<div id=\"Login\">");
            $layout.= trm("<div id=\"Login2\">");
            $layout.= trm("<div class=\"invisible\" id=\"AjaxReport\"></div>");
            $layout.= trm("<PagePart:Body:>");
            $layout.= trm("</div>");
            $layout.= trm("</div>");
            $layout.= trm("</div>");
            $layout.= trm("<div id=\"Footer\">");
            $layout.= trm("<div class=\"Right\"><a href=\"http://www.davidkorinek.cz\" target=\"_blank\">David Kořínek</a> &copy; 2013 - ".Date("Y")."</div>");
            $layout.= trm("<div class=\"Left\"><a href=\"".$MTPS->PublishingSystemURL."\" target=\"_blank\">".$MTPS->PublishingSystemName."</a></div>");
            $layout.= trm("</div>");
            $layout.= trm("<div class=\"clear\"></div>");
            $layout.= trm("</div>");
            $layout.= trm("</div>");
            $layout.= trm("<div id=\"mnuFirst\"></div><div style=\"display: none\"><PagePart:StatsCodes:></div></body>");
            $layout.= trm("</html>");}
        if($client_layout == 3) {
            $layout.= trm("<!doctype html>");
            $layout.= trm("<head lang=\"<PagePart:Language:>\">");
            $layout.= trm("<meta http-equiv=\"content-type\" content=\"text/html; charset=<PagePart:Charset:>\" />");
            $layout.= trm("<meta name=\"viewport\" content=\"target-densitydpi=device-dpi\">");
            $layout.= trm("<meta name=\"viewport\" content=\"width=device-width\">");
            $layout.= trm("<meta name=\"viewport\" content=\"target-densitydpi=device-dpi, width=device-width, initial-scale=1.0\" />");
            if(IsSet($MTPS->Favicon) && $MTPS->Favicon != "") { $layout.= trm("<link rel=\"shortcut icon\" type=\"image/x-icon\" href=\"".$MTPS->Favicon."\" />"); }
            $layout.= trm("<link rel=\"stylesheet\" type=\"text/css\" href=\"".$GLOBALS['urlCSS']."mtps<PagePart:MTPSReleaseTime:>.css\" />");
            $layout.= trm("<link rel=\"stylesheet\" type=\"text/css\" href=\"".$GLOBALS['urlCSS']."user<PagePart:MTPSReleaseTime:>.css\" />");
            $layout.= trm("<script src=\"<PagePart:urlJS:>mtps<PagePart:MTPSReleaseTime:>.js\"></script>");
            $layout.= trm("<script src=\"<PagePart:urlJS:>dialogs<PagePart:MTPSReleaseTime:>.js\"></script>");
            $layout.= trm("<script src=\"".$GLOBALS['urlJS']."user<PagePart:MTPSReleaseTime:>.js?url=".urlencode($MTPS->URL)."\"></script>");
            $layout.= trm("<title><PagePart:Title:></title>");
            $layout.= trm("</head>");
            $Web->OnLoad = "BodyLoad(".$MTPS->ClientLayout.");";
            $Web->OnResize = "BodyResize(".$MTPS->ClientLayout.");";
            $Web->OnMouseUp = "BodyMouseUp(".$MTPS->ClientLayout.");";
            if($Web->OnLoad != "") { $onload = " onload=\"mtpsLoadPageImages();".$Web->OnLoad."\""; } else { $onload = " onload=\"mtpsLoadPageImages();\""; }
            if($Web->OnResize != "") { $onresize = " onresize=\"".$Web->OnResize."\""; } else { $onresize = ""; }
            if($Web->OnMouseUp != "") { $onmouseup = " onmouseup=\"".$Web->OnMouseUp."\""; } else { $onmouseup = ""; }
            $layout.= trm("<body lang=\"<PagePart:Language:>\"$onload$onmouseup$onresize>");
            $layout.= trm("<div id=\"Desk\"><div class=\"invisible\" id=\"AjaxReport\"></div><PagePart:Body:></div>");
            $layout.= trm("<div id=\"Overlay\" onclick=\"OverlayClick();\"></div><div id=\"mnuFirst\"></div><div style=\"display: none\"><PagePart:StatsCodes:></div></body>");
            $layout.= trm("</html>");}
        return $layout;}}
class WEB {
    public $Part;
    public $IsScript = false;
    public $Module = "";
    public $Section = "";
    public $Layout = "";
    public $ContentLayout = "";
    public $OnLoad = "";
    public $OnResize = "";
    public $OnMouseUp = "";
    public $OnMouseDown = "";
    public $OnKeyDown = "";
    public $OnBeforeUnload = "";
    public function initialLocationHandler() {
        global $MTPS;
        $ok = false;
        if(!$ok && $MTPS->PathOne == lnUrl(1)) {
            $MTPS->IsIndexPage = true;
            $ok = true;
        }
        return $ok;
    }
    public function loadAndWritePage($___url=false) {
        if(!Settings('EnablePages')) { return ""; }
        global $MTPS, $DB, $News, $Eshop, $urlWEB, $urlLOGIN;
        $bodyContent = "";
        $prfx = "";
        if($MTPS->IsIndexPage) { $prfx = "index-"; }
        $bodyContent.= "<div class=\"".$prfx."page-main-content-wrapper\">";
        if(Settings('WebIsWorkInProgress')) { AddReport("Na přípravě webu usilovně pracujeme. Přijďte se podívat zítra, třeba to již bude hotové."); }
        if(Settings('ShowTrainingWebInfo')) { if(CanAdmin()) { AddReport("Nacházíte se ve cvičné verzi webu a jste přihlášeni; můžete tu dělat, co Vás napadne."); } else { AddReport("Nacházíte se ve cvičné verzi webu, ale nejste přihlášeni. <a href=\"".$urlLOGIN."\">Přihlaste se ZDE</a>."); } }
        $url = "";
        if($___url !== false) {
            $___pathCount = $MTPS->PathCount;
            $___path = $MTPS->Path;
            $___pathOne = $MTPS->PathOne;
            $___pathTwo = $MTPS->PathTwo;
            $___pathThree = $MTPS->PathThree;
            $___pathFour = $MTPS->PathFour;
            $___pathFive = $MTPS->PathFive;
            $MTPS->PathCount = 0;
            $MTPS->Path = "";
            $MTPS->PathOne = "";
            $MTPS->PathTwo = "";
            $MTPS->PathThree = "";
            $MTPS->PathFour = "";
            $MTPS->PathFive = "";
            $MTPS->Path = UrlPathToArray($___url,$MTPS->PathCount,$language_in_path);
            if(IsSet($MTPS->Path[0])) { $MTPS->PathOne = strtolower($MTPS->Path[0]); }
            if(IsSet($MTPS->Path[1])) { $MTPS->PathTwo = strtolower($MTPS->Path[1]); }
            if(IsSet($MTPS->Path[2])) { $MTPS->PathThree = strtolower($MTPS->Path[2]); }
            if(IsSet($MTPS->Path[3])) { $MTPS->PathFour = strtolower($MTPS->Path[3]); }
            if(IsSet($MTPS->Path[4])) { $MTPS->PathFive = strtolower($MTPS->Path[4]); }
        }
        for($aa=0; $aa<$MTPS->PathCount; $aa++) {
            $url.= $MTPS->Path[$aa]."/";
        }
        $page_language = $MTPS->Language;

        $page = $this->LoadPageByURL($url,$page_language);
        error_log("page->Type ".$page->Type);

        $MTPS->Page = $page;
        if($page !== false) {
            if($page->Type == 100 && $page->ID != $page->RedirectTo && ($new_page = $this->LoadPageByID($page->RedirectTo)) !== false) {
                $redirect_to = $this->GetPagePathByID($new_page->ID,$MTPS->Language);
                LinkReload($urlWEB.$redirect_to);
            }
            $MTPS->PageParents = $DB->SelectSuperiorTree("Pages",$page,0,$MTPS->PageParentsCount,"`SortPos` ASC, `Created` ASC");
            if($MTPS->PageParents !== false) {
                for($aa=0; $aa<$MTPS->PageParentsCount; $aa++) {
                    AddNavigation(LngStr($MTPS->PageParents[$aa]->Title),$urlWEB.$this->GetPagePathByID($MTPS->PageParents[$aa]->ID,$MTPS->Language));}
            }
            $MTPS->SectionFound = true;
            $MTPS->PageID = $page->ID;
            $MTPS->Title = LngStr($page->Title);
            $MTPS->OGType = "article";
            $MTPS->OGPageTitle = $this->CreatePageTitle();
            $content_orders=0;
            //if((CanAdmin('edit-local-tv') && $page->Type == 9) || ($page->ShowTitle && !Settings("NeverShowTitleInPage",true))) {
            //    if($page->Type == 8 && Settings('EnableInstitutions')) { $bodyContent.= $this->Institutions_WriteMainTitle(LngStr($page->Title),$page->RedirectTo); }
            //    else if($page->Type == 9 && Settings('EnableLocalTV')) { $bodyContent.= LocalTV_WriteMainTitle(LngStr($page->Title)); }
            //    else if($page->Type == 20 && defined("reference-pages")) { $bodyContent.= ReferencePages_WriteMainTitle(LngStr($page->Title)); }
            //    else { $bodyContent.= "<h1>".LngStr($page->Title)."</h1>"; }}
            //if(Settings('GalleryAlbumsOnHomepage') && $MTPS->PathOne == "" || $MTPS->PathOne == "index" || $MTPS->PathOne == "index.php") {
            //    $bodyContent.= $this->writeGalleryAlbumsOnHomepage();
            //}
            $additional_content = "";
            if(defined("odoprag.cz") && $page->Type == 14) {
                $additional_content = "<p style=\"color: blue; font-size: 125%; font-weight: bold; margin-bottom: .5em;\">Uvedené ceny v ceníku <u>jsou konečné</u>, nejsme plátci DPH.</p>";
                $additional_content.= "<p style=\"color: blue; font-size: 125%; font-weight: bold; margin-bottom: .5em;\">Tento ceník platí pro následující destinace: ČR, Polsko, Německo, Rakousko, Maďarsko, Slovensko,Chorvatsko, Slovinsko, Itálii. </p>";
//                $additional_content.= "<p style=\"color: blue; font-size: 125%; font-weight: bold; margin-bottom: .5em;\">Ceny pronájmu vozů, mířících do dalších zemí EU nebo mimo EU jsou stanovené individuálně  na základě konkrétní poptávky s ohledem na nájezd km, charakter destinace, počet dnů a typ vozu. </p>";
                $additional_content.= "<br>";

                $additional_content .= $this->OdopragCz_Pricelist_bySkupina();

                $additional_content.= "<p>Tento ceník platí pro následující destinace: ČR, Polsko, Německo, Rakousko, Maďarsko, Slovensko,Chorvatsko, Slovinsko, Itálii. </p>";
                $additional_content.= "<p>Ceny pronájmu vozů, mířících do dalších zemí EU nebo mimo EU jsou stanovené individuálně  na základě konkrétní poptávky s ohledem na nájezd km, charakter destinace, počet dnů a typ vozu. </p>";
                $additional_content.= "<br>";

                $content_orders=1;
            }

            error_log("page->Type ".$page->Type);
            if(defined("odoprag.cz") && $page->Type == 25) {
                error_log("pred CarFleet");
                $additional_content = $this->CarFleetV21();
            }

            error_log("page->Type ".$page->Type);
            if(defined("odoprag.cz") && $page->Type == 24) {
                error_log("pred CarFleet");
                $additional_content = $this->CarFleet();
            }

            if(defined("odoprag.cz") && $page->Type == 108) {
                error_log("loadAndWritePage CarID ".$page->CarID);
                //$additional_content = $this->CarFleet();
                $additional_content = $this->CarFleet_WriteOneCarV2($page->CarID);
//                $additional_content .= "<script>karel();</script>" ;
            }
            
            if($page->ShowAttachments == 2 || $page->ShowAttachments == 3) {
                $bodyContent.= $this->WritePageAttachments($page->ID);
            }
            if($page->ShowSubpages == 2 || $page->ShowSubpages == 3)
            {
                $bodyContent.= $this->WriteListOfNextPages($page->ID,true,2);
            }
            $page_content = $this->LoadPageContent($page->ID,$page_language,true,$MTPS->MakeImagesClickable);

            if($page->Description != "") {
                $MTPS->WebDescription = $page->Description;
                $MTPS->OGPageDescription = $page->Description;
            }

            if($page_content !== false) {
                $MTPS->PageID = $this->GetShortText($page_content->Content,30);
                if($page_language != $MTPS->Language) {
                    AddReport("Content of this page is not available in selected language (".$MTPS->Language.").");}
                if($page_content->Content == "<p></p>") {
                    $page_content->Content = "";
                }
                
                if($content_orders) {
                   $bodyContent.= "<div id=\"Content\" class=\"content\">".$additional_content.$page_content->Content."</div>";
                } else {
                   $bodyContent.= "<div id=\"Content\" class=\"content\">".$page_content->Content.$additional_content."</div>";
                }

            } else if($MTPS->Language != $MTPS->SupportedLanguages[0] && ($page_content = $this->LoadPageContent($page->ID,$MTPS->SupportedLanguages[0],true,$MTPS->MakeImagesClickable))) {
                AddReport("Content of this page is not available in selected language (".$MTPS->Language.").");
                if($page_content->Content == "<p></p>") { $page_content->Content = ""; }
                $bodyContent.= "<div id=\"Content\" class=\"content\">".$page_content->Content.$additional_content."</div>";}
            else {
                $bodyContent.= "<div id=\"Content\" class=\"content\">".$additional_content."</div>";}
            if($page->Type == 1) {
                $bodyContent.= WEB_Gallery_WriteAllAlbums();}
            if($page->Type == 2) {
                if(($newsString = $News->getPublishedNews()) !== false) {
                    $bodyContent.= $newsString;}
                else {
                    $bodyContent.= WEB_News_WriteMainTitle();
                    $bodyContent.= WEB_News_WriteShortNews();}}
            if($page->Type == 4) {
                $bodyContent.= $this->WriteMapOfWeb();}
            if($page->Type == 5 && Settings('CreateContactListFromUsers',true)) {
                $bodyContent.= $this->Contacts_WriteContactListFromUsers();}
            if($page->Type == 6 && Settings('EnableDocumentsToDownloadByDepartments',true)) {
                $bodyContent.= $this->Downloads_WriteDocumentsByDepartments();}
            if($page->Type == 7 && Settings('EnableCalendar',true)) {
                $bodyContent.= WEB_Calendar_WriteFullCalendar();}
            if($page->Type == 8 && Settings('EnableInstitutions')) {
                $bodyContent.= $this->WriteInstitutions($page->RedirectTo);}
            if($page->Type == 19 && Settings('EnableContactForm')) {
                $bodyContent.= $this->WriteContactForm();}
            if(CanAdmin("pages-administration",$page->ID)) {
                $bodyContent.= "<div class=\"mtps-page-admin\">";
                $bodyContent.= "<h2>".Lng('Administration').":</h2>";
                $bodyContent.= "<p class=\"mtps-page-buttons\" id=\"InPageAdministrationButtons\">";
                $bodyContent.= $this->Pages_WriteInPageAdministrationButtons("admin",$page);
                $bodyContent.= "</p>";
                $bodyContent.= "</div>";}
            if($page->ShowAttachments == 1 || $page->ShowAttachments == 3 || CanAdmin()) { $bodyContent.= $this->WritePageAttachments($page->ID); }
            if($page->ShowSubpages == 1 || $page->ShowSubpages == 3 || CanAdmin()) { $bodyContent.= $this->WriteListOfNextPages($page->ID,true,1); }
        } else {
            for($pp=0; $pp<5; $pp++) {
                $url_before = "";
                for($aa=0; $aa<$MTPS->PathCount-1-$pp; $aa++) { $url_before.= $MTPS->Path[$aa]."/"; }
                $page_before = $this->LoadPageByURL($url_before,$MTPS->Language);
                if($page_before !== false) {
                    $MTPS->Page = $page_before;
                    if($page_before->Type == 1 && Settings("EnableGallery")) {
                        $MTPS->SectionFound = true;
                        $MTPS->PageID = $page_before->ID;
                        $MTPS->Title = LngStr($page_before->Title);
                        $MTPS->OGType = "article";
                        $MTPS->OGPageTitle = "k " . $this->CreatePageTitle();
                        $MTPS->PageParents = $DB->SelectSuperiorTree("Pages",$page_before,0,$MTPS->PageParentsCount,"`SortPos` ASC, `Created` ASC");
                        if($MTPS->PageParents !== false) {
                            for($aa=0; $aa<$MTPS->PageParentsCount; $aa++) {
                                AddNavigation(LngStr($MTPS->PageParents[$aa]->Title),$urlWEB.$this->GetPagePathByID($MTPS->PageParents[$aa]->ID,$MTPS->Language));}}
                        $item_id = $MTPS->Path[$MTPS->PathCount-1];
                        if(($pos = strpos($MTPS->Path[$MTPS->PathCount-1],"-")) !== false) { $item_id = substr($MTPS->Path[$MTPS->PathCount-1],0,$pos); }
                        $bodyContent.= Web_Gallery_WriteAlbum($item_id);
                    }
                    if($page_before->Type == 5 && Settings('CreateContactListFromUsers',true)) {
                        $MTPS->SectionFound = true;
                        $MTPS->PageID = $page_before->ID;
                        $MTPS->PageParents = $DB->SelectSuperiorTree("Pages",$page_before,0,$MTPS->PageParentsCount,"`SortPos` ASC, `Created` ASC");
                        if($MTPS->PageParents !== false) {
                            for($aa=0; $aa<$MTPS->PageParentsCount; $aa++) {
                                AddNavigation(LngStr($MTPS->PageParents[$aa]->Title),$urlWEB.$this->GetPagePathByID($MTPS->PageParents[$aa]->ID,$MTPS->Language));}}
                        $item_id = $MTPS->Path[$MTPS->PathCount-1];
                        if(($pos = strpos($MTPS->Path[$MTPS->PathCount-1],"-")) !== false) { $item_id = substr($MTPS->Path[$MTPS->PathCount-1],0,$pos); }
                        $bodyContent.= $this->Contacts_WriteContact($item_id);
                    }
                    if($page_before->Type == 7 && Settings('EnableCalendar',true)) {
                        $MTPS->SectionFound = true;
                        $MTPS->PageID = $page_before->ID;
                        $MTPS->PageParents = $DB->SelectSuperiorTree("Pages",$page_before,0,$MTPS->PageParentsCount,"`SortPos` ASC, `Created` ASC");
                        if($MTPS->PageParents !== false) {
                            for($aa=0; $aa<$MTPS->PageParentsCount; $aa++) {
                                AddNavigation(LngStr($MTPS->PageParents[$aa]->Title),$urlWEB.$this->GetPagePathByID($MTPS->PageParents[$aa]->ID,$MTPS->Language));}}
                        $item_id = $MTPS->Path[$MTPS->PathCount-1];
                        if(($pos = strpos($MTPS->Path[$MTPS->PathCount-1],"-")) !== false) { $item_id = substr($MTPS->Path[$MTPS->PathCount-1],0,$pos); }
                        $bodyContent.= WEB_Calendar_WriteItem($item_id);
                    }
                    if(Settings('EnableSportEventsDonations') && $page_before->Type == 10) {
                        $MTPS->SectionFound = true;
                        $MTPS->PageID = $page_before->ID;
                        $MTPS->SubpagesEditable = false;
                        $MTPS->PageParents = $DB->SelectSuperiorTree("Pages",$page_before,0,$MTPS->PageParentsCount,"`SortPos` ASC, `Created` ASC");
                        if($MTPS->PageParents !== false) {
                            for($aa=0; $aa<$MTPS->PageParentsCount; $aa++) {
                                AddNavigation(LngStr($MTPS->PageParents[$aa]->Title),$urlWEB.$this->GetPagePathByID($MTPS->PageParents[$aa]->ID,$MTPS->Language));}}
                        $bodyContent.= SportDonations_WriteFullPage($MTPS->PageParentsCount-1);
                    }
                    break;
                }
            }
        }
                
        $bodyContent.= "<div class=\"clear-both\"></div></div>";
        if($___url !== false) {
            $MTPS->PathCount = $___pathCount;
            $MTPS->Path = $___path;
            $MTPS->PathOne = $___pathOne;
            $MTPS->PathTwo = $___pathTwo;
            $MTPS->PathThree = $___pathThree;
            $MTPS->PathFour = $___pathFour;
            $MTPS->PathFive = $___pathFive;}
        if(!$MTPS->SectionFound) {
            return "";
        }
        return $bodyContent;
    }
    
    public function Pages_RenamePage($values,&$arr) {
        global $MTPS;
        if(IsSet($values['PageID']) && is_numeric($values['PageID']) && $values['PageID'] > 0) {
            if(!CanAdmin("rename-page",$values['PageID'],$arr['Response'])) { return false; }
            $lngcount = 0;
            foreach($MTPS->SupportedLanguages as $key => $lng) {
                if($lngcount == 0 && (!IsSet($values['Title_'.$lng]) || strlen($values['Title_'.$lng]) < 3)) { $arr['Response'] = "[WEB:Pages_RenamePage] Title in main language (".$lng.") is not defined or is too short (min. 3 characters)!"; return false; }
                if(IsSet($values['Title_'.$lng]) && strlen($values['Title_'.$lng]) >= 3) {
                    if(!$this->Pages_RenamePage_OneLanguage($values['PageID'],$lng,$values['Title_'.$lng],$arr['Response'])) {
                        return false;}}
                $lngcount++;}
            $arr['ReloadToURL'] = AddSlashToEnd($GLOBALS['urlWEB'].$this->GetPagePathByID($values['PageID'],$MTPS->Language));
            return true;}
        else {
            $arr['Response'] = "[WEB:Pages_RenamePage] PageID value is not defined!";}
        return false;}
    public function Pages_RenamePage_OneLanguage($page_id,$lng,$new_title,&$response,$force_rename=false) {
        if(IsSet($page_id) && is_numeric($page_id) && $page_id > 0) {
            if(!CanAdmin("rename-page",$page_id,$response)) { return false; }
            if(($page = $this->LoadPageByID($page_id)) !== false) {
                $new_title_folder_name = PageNameToDirName($new_title);
                $titles = json_decode($page->Title,true);
                if(!$force_rename && IsSet($titles[$lng]) && $titles[$lng] != "" && PageNameToDirName($titles[$lng]) == $new_title_folder_name) {
                    $titles[$lng] = $new_title;
                    return $this->UpdatePageTitle($page_id,$titles,$response);}
                if($force_rename || strlen($new_title) >= 3) {
                    $titles[$lng] = $new_title;
                    if($this->UpdatePageTitle($page_id,$titles,$response)) {
                        if(!$this->Pages_RenameAttachmentsFolder($page_id,$lng,$new_title_folder_name,$response) && $page->ParentID > 0) { return false; }
                        if(!$this->Pages_RenameImagesFolder($page_id,$lng,$new_title_folder_name,$response) && $page->ParentID > 0) { return false; }
                        $this->UpdatePageContentImagesPath($page_id,$lng,$new_title_folder_name,$response);
                        if(!$this->UpdatePagePathByID($page_id,$lng,$new_title_folder_name,$page->ParentID,$response)) { return false; }
                        return true;}}
                else {
                    $response = "[WEB:Pages_RenamePage_OneLanguage] New page-name is too short!";}}
            else {
                $response = "[WEB:Pages_RenamePage_OneLanguage] Page not found!";}}
        else {
            $response = "[WEB:Pages_RenamePage_OneLanguage] PageID value is not defined!";}
        return false;}
    private function LoadPagesByParentID($parent_id,&$count) {
        global $DB;
        if(($pages = $DB->Select("Pages","`ParentID`=".DBText($parent_id),$count,"`SortPos` ASC")) !== false && $count > 0) {
            return $pages;}
        return false;}
    function GetShortText($text,$words_count,&$news_text="") {
        $news_text = str_replace("&nbsp;"," ",$text);
        $news_text = str_replace("</div>","</div> ",$news_text);
        $news_text = str_replace("</p>","</p> ",$news_text);
        $news_text = str_replace("<br />"," ",$news_text);
        $news_text = str_replace(" "," ",$news_text);
        $news_text = strip_tags($news_text);
        $news_text = html_entity_decode($news_text);
        $news_text = $this->DeleteEmptyParts($news_text);
        return implode(' ',array_slice(explode(' ',$news_text),0,$words_count));}
    
    private function UpdatePageContentImagesPath($page_id,$language,$new_folder_name,&$response="") {
        global $DB;
        if(!CanAdmin("rename-page",$page_id,$response)) { return false; }
        if(($subpath = $this->GetPagePathByID($page_id,$language)) != "") {
            $old_path = AddSlashToEnd("gallery/".LngPath($language)."pages/".$subpath);
            $new_path = RemoveLastFolderFromPath($old_path).$new_folder_name."/";
            if(($content = $DB->Select("PagesContents","`PageID`=".DBText($page_id)." AND `Language`='".DBText($language)."'",$count,"`Published` DESC")) !== false && $count > 0) {
                for($aa=0; $aa<$count; $aa++) {
                    $content[$aa]->Content = @str_replace($old_path,$new_path,$content[$aa]->Content);
                    $DB->Update("PagesContents","`Content` = '".DBText($content[$aa]->Content)."', `PlainContent` = '".DBText(GetPlainText($content[$aa]->Content,"-"))."', ","`ID` = '".DBText($content[$aa]->ID)."'");}}
            return true;}
        return false;}
    
    private function UpdatePagePathByID($page_id,$language,$new_folder_name,$superior_page_id,&$response="") {
        global $DB;
        if(!CanAdmin("rename-page",$page_id,$response)) { return false; }
        if($superior_page_id > 0) {
            $url = $this->GetPagePathByID($superior_page_id,$language);
            $url.= $new_folder_name.'/';}
        else {
            $url = '';}
        if(($urls = $DB->Select("PagesURLs","`PageID`=".DBText($page_id)." AND `Language`='".DBText($language)."'",$urls_count,"`Changed` DESC")) !== false && $urls_count > 0) {
            if($DB->Update("PagesURLs","`URL` = '".DBText($url)."', ","`PageID`=".DBText($page_id)." AND `Language`='".DBText($language)."'",$response)) {
                if(($pages = $DB->Select("Pages","`ParentID`=".DBText($page_id),$count)) !== false && $count > 0) {
                    for($aa=0; $aa<$count; $aa++) {
                        $titles = json_decode($pages[$aa]->Title,true);
                        if(IsSet($titles[$language]) && $titles[$language] != "") {
                            if($pages[$aa]->ID != $page_id) {
                                $this->UpdatePagePathByID($pages[$aa]->ID,$language,PageNameToDirName($titles[$language]),$page_id,$response);}}}}
                return true;}}
        else {
            if(IsSet($data)) { UnSet($data); }
            $data['PageID'] = $page_id;
            $data['Language'] = $language;
            $data['URL'] = $url;
            return $DB->Insert("PagesURLs",$data);}
        return false;}
    private function Pages_RenameAttachmentsFolder($page_id,$language,$new_folder_name,&$response) {
        global $DB, $MTPS;
        if(!CanAdmin("rename-page",$page_id,$response)) { return false; }
        if(($subpath = $this->GetPagePathByID($page_id,$language)) != "") {
            $old_path = AddSlashToEnd($GLOBALS['fileWEB']."files/".LngPath($language)."pages/".$subpath);
            $new_path = RemoveLastFolderFromPath($old_path).$new_folder_name."/";
            if(!file_exists($old_path) || rename($old_path,$new_path)) {
                return true;}
            else {
                $response = "[WEB:Pages_RenameAttachmentsFolder] Error while renaming ".$old_path." to ".$new_path;}}
        else {
            $response = "[WEB:Pages_RenameAttachmentsFolder] Page path not found!";}
        return false;}
    private function Pages_RenameImagesFolder($page_id,$language,$new_folder_name,&$response) {
        global $DB, $MTPS;
        if(!CanAdmin("rename-page",$page_id,$response)) { return false; }
        if(($subpath = $this->GetPagePathByID($page_id,$language)) != "") {
            $old_path = AddSlashToEnd($GLOBALS['fileWEB']."gallery/".LngPath($language)."pages/".$subpath);
            $new_path = RemoveLastFolderFromPath($old_path).$new_folder_name."/";
            if(!file_exists($old_path) || rename($old_path,$new_path)) {
                return true;}
            else {
                $response = "[WEB:Pages_RenameImagesFolder] Error while renaming ".$old_path." to ".$new_path;}}
        else {
            $response = "[WEB:Pages_RenameImagesFolder] Page path not found!";}
        return false;}
    private function UpdatePageTitle($page_id,$title_obj,&$response="") {
        global $DB;
        return $DB->Update("Pages","`Title` = '".DBText(JsonEncode($title_obj))."', ","`ID` = '".DBText($page_id)."'",$response);
    }
    
    public function LoadPageByURL($url,&$language) {
        global $DB, $MTPS;
        $url_pos = -1;
        $where = "`URL`='".DBText($url)."'";
        if($url == "") { $where = "(".$where." OR `URL`='".DBText("/")."')"; }
        if(($urls = $DB->Select("PagesURLs",$where,$urls_count,"`Changed` DESC")) !== false && $urls_count > 0) {
            for($aa=0; $aa<$urls_count; $aa++) {
                if($urls[$aa]->Language == $language) { $url_pos = $aa; break; }}
            if($url_pos == -1) {
                foreach($MTPS->SupportedLanguages as $key => $lng) {
                    for($aa=0; $aa<$urls_count; $aa++) {
                        if($urls[$aa]->Language == $lng) { $url_pos = $aa; break; }}
                    if($url_pos != -1) { break; }}}
            $language = $urls[$url_pos]->Language;}
        if($url_pos > -1) {
            $where2 = "`ID`=".DBText($urls[$url_pos]->PageID);
            if(($rows2 = $DB->Select("Pages",$where2,$count2,"`Changed` DESC","1")) !== false && $count2 > 0) {
                return $rows2[0];}}
        return false;
    }

    public function LoadPageByID($page_id) {
        global $DB;
        if(($pages = $DB->Select("Pages","`ID` = '".DBText($page_id)."'",$count)) !== false && $count > 0) {
            return $pages[0];}
        return false;}
    public function GetPagePathByID($page_id,$language) {
        global $DB, $MTPS;
        $where = "`PageID`=".DBText($page_id)." AND `Language`='".DBText($language)."'";
        if(($rows = $DB->Select("PagesURLs",$where,$count,"`Changed` DESC","1")) !== false && $count > 0) {
            return $rows[0]->URL;}
        foreach($MTPS->SupportedLanguages as $key => $lng) {
            if($lng != $language) {
                $where = "`PageID`=".DBText($page_id)." AND `Language`='".DBText($lng)."'";
                if(($rows = $DB->Select("PagesURLs",$where,$count,"`Changed` DESC","1")) !== false && $count > 0) {
                    return $rows[0]->URL;}}}
        return "";
    }

    public function LoadPageContent($page_id,$language,$published_only=true,$make_images_clickable=false) {
        global $DB, $MTPS;
        if($published_only) { $published = " AND `Published`>0"; } else { $published = ""; }
        $where = "`PageID`=".DBText($page_id)."$published AND `Language`='".DBText($language)."'";
        if(($content = $DB->Select("PagesContents",$where,$count,"`Published` DESC","1")) !== false && $count > 0) {
            $content[0]->Content = @str_replace("\r\n",chr(32),$content[0]->Content);
            $content[0]->Content = @str_replace("\n",chr(32),$content[0]->Content);
            $content[0]->Content = @str_replace("https://".AddSlashToEnd($_SERVER['HTTP_HOST']).$MTPS->Language."/","<PagePart:imgWEB:>",$content[0]->Content);
            $content[0]->Content = @str_replace("http://".AddSlashToEnd($_SERVER['HTTP_HOST']).$MTPS->Language."/","<PagePart:imgWEB:>",$content[0]->Content);
            $content[0]->Content = @str_replace("https://".AddSlashToEnd($_SERVER['HTTP_HOST']),"<PagePart:imgWEB:>",$content[0]->Content);
            $content[0]->Content = @str_replace("http://".AddSlashToEnd($_SERVER['HTTP_HOST']),"<PagePart:imgWEB:>",$content[0]->Content);
            $content[0]->Content = @str_replace("https://".AddSlashToEnd($MTPS->SecondaryHttpHost).$MTPS->Language."/","<PagePart:imgWEB:>",$content[0]->Content);
            $content[0]->Content = @str_replace("http://".AddSlashToEnd($MTPS->SecondaryHttpHost).$MTPS->Language."/","<PagePart:imgWEB:>",$content[0]->Content);
            $content[0]->Content = @str_replace("https://www.".AddSlashToEnd($MTPS->SecondaryHttpHost).$MTPS->Language."/","<PagePart:imgWEB:>",$content[0]->Content);
            $content[0]->Content = @str_replace("http://www.".AddSlashToEnd($MTPS->SecondaryHttpHost).$MTPS->Language."/","<PagePart:imgWEB:>",$content[0]->Content);
            $content[0]->Content = @str_replace("https://".AddSlashToEnd($MTPS->SecondaryHttpHost),"<PagePart:imgWEB:>",$content[0]->Content);
            $content[0]->Content = @str_replace("http://".AddSlashToEnd($MTPS->SecondaryHttpHost),"<PagePart:imgWEB:>",$content[0]->Content);
            $content[0]->Content = @str_replace("https://www.".AddSlashToEnd($MTPS->SecondaryHttpHost),"<PagePart:imgWEB:>",$content[0]->Content);
            $content[0]->Content = @str_replace("http://www.".AddSlashToEnd($MTPS->SecondaryHttpHost),"<PagePart:imgWEB:>",$content[0]->Content);
            if($make_images_clickable) {
                $imgpos = 0;
                $text = "";
                $content[0]->Content = @str_replace("<PagePart:imgWEB:>gallery/","",$content[0]->Content);
                while(($imgpos = strpos($content[0]->Content,"<img")) !== false) {
                    $text.= substr($content[0]->Content,0,$imgpos);
                    if($imgpos > 0) { $content[0]->Content = substr($content[0]->Content,$imgpos); }
                    if(($endpos = strpos($content[0]->Content,">")) !== false) {
                        $img = substr($content[0]->Content,0,$endpos+1);
                        $content[0]->Content = substr($content[0]->Content,$endpos+1);
                        $params = GetParamsFromImg($img);
                        if(strlen($GLOBALS['fileWEB']."gallery/".LngPath($language).RemoveDomainAndGalleryFromPath($params['src'])) < 4096 && is_file($GLOBALS['fileWEB']."gallery/".LngPath($language).RemoveDomainAndGalleryFromPath($params['src']))) {
                            if(($size = @getimagesize($GLOBALS['fileWEB']."gallery/".LngPath($language).RemoveDomainAndGalleryFromPath($params['src']))) !== false) {
                                $img_width = intval($size[0],10);
                                $img_height = intval($size[1],10);}
                            else {
                                $img_width = $MTPS->MaxInPageImageWidth*$MTPS->EM;
                                $img_height = intval($size[1],10);}
                            if($img_width > $MTPS->MaxInPageImageWidth*$MTPS->EM) {
                                $img_width = $MTPS->MaxInPageImageWidth*$MTPS->EM;}
                            if(IsSet($params['width']) && $img_width > ($size_in_pixels = GetSizeInPixels($params['width']))) {
                                $img_width = $size_in_pixels;}
                            $text.= "<a href=\"".$GLOBALS['imgWEB']."gallery/".LngPath($language).RemoveDomainAndGalleryFromPath($params['src'])."\" target=\"_blank\" title=\"".htmlspecialchars($params['alt'])."\">";
                            $text.= "<img src=\"".$GLOBALS['imgWEB']."image/file/gallery/".LngPath($language).RemoveDomainAndGalleryFromPath($params['src'])."?Width=".$img_width."\" style=\"".htmlspecialchars($params['style'])."\" alt=\"".htmlspecialchars($params['alt'])."\" />";
                            $text.= "</a>";}
                        else {
                            $text.= $img;}}
                    else {
                        if($imgpos == 0) { break; }}}
                $text.= substr($content[0]->Content,0);
                $content[0]->Content = $text;}
            if($make_images_clickable) {
                for($aa=0; $aa<5; $aa++) {
                    $start = 0; $pos0 = 0;
                    if(($script = FindBetween($content[0]->Content,"&lt;script","&lt;/script&gt;",$start,$posX)) != "") {
                        $script = "&lt;script".$script."&lt;/script&gt;";
                        $new_script = $script;
                        @$new_script = str_replace("&lt;","<",$new_script);
                        @$new_script = str_replace("&gt;",">",$new_script);
                        $content[0]->Content = @str_replace($script,$new_script,$content[0]->Content);}}}
            $content[0]->Content = $this->CleanPageContentCSS($content[0]->Content);
            return $content[0];}
        return false;}
    function CleanPageContentCSS($content) {
        while(($str = FindBetween($content,"margin-right:-",";",$start,$posX)) != "") {
            $content = @str_replace("margin-right:-".$str.";","",$content);}
        while(($str = FindBetween($content,"margin-right: -",";",$start,$posX)) != "") {
            $content = @str_replace("margin-right: -".$str.";","",$content);}
        return $content;}
    function SavePageContent(&$content_id,$page_id,$language,$content,&$response) {
        global $DB, $User;
        $response = "[WEB::SavePageContent]";
        if(IsSet($data)) { UnSet($data); }
        $data['PageID'] = $page_id;
        $data['Language'] = $language;
        $data['Published'] = Time();
        $data['Content'] = $content;
        $data['PlainContent'] = GetPlainText($content,"-");
        $data['CreatedByUserID'] = GetUserAccountID();
        $content_id = $DB->Insert("PagesContents",$data);
        if($content_id > 0) { return true; }
        return false;}
    function PublishPageContent(&$content_id,$page_id,$language,&$response) {
        global $DB, $User;
        $response = "[WEB::PublishPageContent]";
        if($content_id > 0) {
            $set = "`Published` = '".DBText(Time())."', ";
            if($DB->Update("PagesContents",$set,"`ID` = '".DBText($content_id)."' AND `PageID`=".DBText($page_id)." AND `Language`='".DBText($language)."'")) {
                return true;}
            return false;}
        return true;}
    function GetNewsPathByID($news_id,$language) {
        global $DB;
        $where = "`ID` = '".DBText($news_id)."'";
        if(($rows = $DB->Select("News",$where,$count,"`Changed` DESC","1")) !== false && $count > 0) {
            $attdate = explode("-",$rows[0]->CreatedDate);
            return $attdate[0]."/".$attdate[1]."/".$attdate[2]."/".$rows[0]->ID."/";}
        return "";}
    function GetZMRMPathByID($zmrm_id,$language) {
        return $zmrm_id;}
    function WritePageAttachments($page_id,$write_div=true,$language="") {
        global $DB, $MTPS;
        if($language == "") { $language = $MTPS->Language; }
        $str = "";
        if(Settings('PageAttachments_NewestAtBottom',true)) { $att_sort = "ASC"; } else { $att_sort = "DESC"; }
        if(Settings('EnablePagesAttachments',true) && ($attachments = $DB->Select("PagesAttachments","`PageID`=".DBText($page_id)." AND `Published`=1",$count,"`SortPos` $att_sort, `Created` ASC")) !== false) {
            if($count > 0 || CanAdmin()) {
                if($write_div) { $str.= "<div class=\"mtps-page-attachments\" id=\"ListOfPageAttachments\">"; }
                $str.= "<h2>".Lng('Attachments').":</h2>";
                if($count > 0) { $str.= "<table>"; }
                for($aa=0; $aa<$count; $aa++) {
                    $admin_tr = "";
                    if(CanAdmin("pages-move-attachment",$page_id)) {
                        $admin_tr.= " onmouseenter=\"SetVisibility('ListOfPageAttachments_IconRename".$attachments[$aa]->ID."','visible'); SetVisibility('ListOfPageAttachments_IconDelete".$attachments[$aa]->ID."','visible');\"";
                        $admin_tr.= " onmouseleave=\"SetVisibility('ListOfPageAttachments_IconRename".$attachments[$aa]->ID."','hidden'); SetVisibility('ListOfPageAttachments_IconDelete".$attachments[$aa]->ID."','hidden');\"";}
                    $str.= "<tr id=\"ListOfPageAttachments_Line".$attachments[$aa]->ID."\"$admin_tr>";
                    if(CanAdmin("pages-move-attachment",$page_id) && $count > 1) {
                        if(Settings('UseWhiteAdminArrows')) { $arrtype = "-white"; } else { $arrtype = ""; }
                        if($aa > 0) { $str.= "<td class=\"clickicon\" onclick=\"Pages_MoveAttachment('up',".$page_id.",".$attachments[$aa]->ID."); return false;\" title=\"Posunout přílohu nahoru\"><img src=\"".$GLOBALS['urlIMG']."arrow-up$arrtype-32x32.png\" alt=\"Posunout přílohu nahoru\" /></td>"; } else { $str.= "<td class=\"noclickicon\">&nbsp;</td>"; }
                        if($aa < $count-1) { $str.= "<td class=\"clickicon\" onclick=\"Pages_MoveAttachment('down',".$page_id.",".$attachments[$aa]->ID."); return false;\" title=\"Posunout přílohu dolů\"><img src=\"".$GLOBALS['urlIMG']."arrow-down$arrtype-32x32.png\" alt=\"Posunout přílohu dolů\" /></td>"; } else { $str.= "<td class=\"noclickicon\">&nbsp;</td>"; }}
                    $str.= "<td><a onclick=\"DownloadFile('page-attachment',".$attachments[$aa]->ID."); return false;\" href=\"".AddSlashToEnd($GLOBALS['urlWEB']."files/".LngPath()."pages/".$this->GetPagePathByID($page_id,$MTPS->Language)).$attachments[$aa]->Filename.".".$attachments[$aa]->Extension."\" target=\"_blank\" title=\"Stáhnout soubor ".$attachments[$aa]->Title.".".strtolower($attachments[$aa]->Extension)."\"><img src=\"".GetFileIconByExtension($attachments[$aa]->Extension)."\" alt=\"Soubor ".strtoupper($attachments[$aa]->Extension)."\" />".$attachments[$aa]->Title.".".strtolower($attachments[$aa]->Extension)."</a><span title=\"Velikost souboru\" class=\"file-size\">[".CountFileSizeInOptimalUnits($attachments[$aa]->Size)."]</span></td>";
                    if(CanAdmin("pages-rename-attachment",$page_id)) {
                        $str.= "<td class=\"clickicon\" onclick=\"Dialog_EditTitle(".$attachments[$aa]->ID.",'Přejmenovat přílohu','".$attachments[$aa]->Title."','Pages_RenameAttachment',".$page_id."); return false;\" title=\"Přejmenovat přílohu\"><img style=\"visibility:hidden;\" src=\"".$GLOBALS['urlIMG']."rename-pencil-32x32.png\" alt=\"Přejmenovat přílohu\" id=\"ListOfPageAttachments_IconRename".$attachments[$aa]->ID."\" /></td>";}
                    if(CanAdmin("pages-delete-attachment",$page_id)) {
                        $text = str_replace("\"","&quot;","Opravdu si přejete vymazat přílohu \"".$attachments[$aa]->Title.".".strtolower($attachments[$aa]->Extension)."\"?");
                        $str.= "<td class=\"clickicon\" onclick=\"Dialog_YesCancel(".$attachments[$aa]->ID.",'Vymazat přílohu','$text','Pages_DeleteAttachment',".$page_id."); return false;\" title=\"Vymazat přílohu\"><img style=\"visibility:hidden;\" src=\"".$GLOBALS['urlIMG']."delete-red-32x32.png\" alt=\"Vymazat přílohu\" id=\"ListOfPageAttachments_IconDelete".$attachments[$aa]->ID."\" /></td>";}
                    $str.= "</tr>";}
                if($count > 0) { $str.= "</table>"; }
                if(CanAdmin("pages-add-attachment",$page_id)) {
                    $str.= "<p class=\"mtps-page-buttons\">";
                    $str.= "<a href=\"\" onclick=\"Pages_SaveContent(g_Pages_SuTxID); Pages_AddAttachment(".$page_id."); return false;\"><img src=\"".$GLOBALS['urlIMG']."attachment.png\" alt=\"".Lng('AddAttachment')."\" />".Lng('AddAttachment')."</a>";
                    $str.= "</p>";}
                if($write_div) { $str.= "</div>"; }}}
        return $str;}
    function WriteListOfNextPages($page_id,$write_div=true,$position_in_page=1) {
        global $DB, $MTPS;
        if($MTPS->SubpagesEditable == false) { return ""; }
        if($position_in_page == 2) { $aditional_class = " mtps-top-subpages"; } else { $aditional_class = ""; }
        $str = "";
        if(($position_in_page > 0 || Settings('ImplicitlyShowListOfSubpages',true) || CanAdmin()) && ($subpages = $DB->Select("Pages","`ParentID`=".DBText($page_id),$count,"`SortPos` ASC, `Created` ASC")) !== false) {
            if($count > 0 || CanAdmin()) {
                if(Settings('UseWhiteAdminArrows')) { $arrtype = "-white"; } else { $arrtype = ""; }
                if($write_div) { $str.= "<div class=\"mtps-subpages$aditional_class\" id=\"ListOfPageSubpages\">"; }
                $str.= "<h2>".Lng('MorePages').":</h2>";
                if(CanAdmin("pages-move-subpage",$page_id)) {
                    if($count > 0) { $str.= "<table>"; }
                    for($aa=0; $aa<$count; $aa++) {
                        $admin_tr = "";
                        $str.= "<tr id=\"ListOfPageSubpages_Line".$subpages[$aa]->ID."\"$admin_tr>";
                        if(CanAdmin("pages-move-subpage",$page_id) && $count > 1) {
                            if($aa > 0) { $str.= "<td class=\"clickicon\" onclick=\"Pages_MoveSubpage('up',".$page_id.",".$subpages[$aa]->ID."); return false;\" title=\"Posunout podstránku nahoru\"><img src=\"".$GLOBALS['urlIMG']."arrow-up$arrtype-32x32.png\" alt=\"Posunout podstránku nahoru\" /></td>"; } else { $str.= "<td class=\"noclickicon\">&nbsp;</td>"; }
                            if($aa < $count-1) { $str.= "<td class=\"clickicon\" onclick=\"Pages_MoveSubpage('down',".$page_id.",".$subpages[$aa]->ID."); return false;\" title=\"Posunout podstránku dolů\"><img src=\"".$GLOBALS['urlIMG']."arrow-down$arrtype-32x32.png\" alt=\"Posunout podstránku dolů\" /></td>"; } else { $str.= "<td class=\"noclickicon\">&nbsp;</td>"; }}
                        $str.= "<td><a href=\"".$GLOBALS['urlWEB'].$this->GetPagePathByID($subpages[$aa]->ID,$MTPS->Language)."\">".LngStr($subpages[$aa]->Title)."</a></td>";
                        $str.= "</tr>";}
                    if($count > 0) { $str.= "</table>"; }}
                else {
                    for($aa=0; $aa<$count; $aa++) {
                        $str.= "<p> - <a class=\"subpage-link\" href=\"".$GLOBALS['urlWEB'].$this->GetPagePathByID($subpages[$aa]->ID,$MTPS->Language)."\">".LngStr($subpages[$aa]->Title)."</a></p>";}}
                if(CanAdmin("pages-add-subpage",$page_id)) {
                    $str.= "<p class=\"mtps-page-buttons\">";
                    $str.= "<a href=\"\" onclick=\"Pages_SaveContent(g_Pages_SuTxID); Pages_EditSubPage(".$page_id."); return false;\"><img src=\"".$GLOBALS['urlIMG']."add-green-circle-64x64.png\" alt=\"".Lng('AddSubPage')."\" />".Lng('AddSubPage')."</a>";
                    $str.= "</p>";}
                if($write_div) { $str.= "</div>"; }}}
        return $str;}
    function Pages_AddAttachmentFile(&$attachment_id,$page_id,$filename,$ext,$filesize,&$response,$by_cron=false) {
        global $DB, $MTPS, $User;
        if(!CanAdmin("pages-add-attachment",$page_id,$response) && !$by_cron) { return false; }
        $response = "";
        if(IsSet($data)) { UnSet($data); }
        $data['Type'] = 0;
        $data['ParentID'] = 0;
        $data['PageID'] = $page_id;
        $data['Filename'] = $filename;
        $data['Extension'] = $ext;
        $data['Size'] = $filesize;
        $data['Published'] = 0;
        $data['CreatedByUserID'] = GetUserAccountID();
        if(($attachment_id = $DB->Insert("PagesAttachments",$data,$response)) !== false) {
            return true;}
        if($response == "") { $response = "[WEB::Pages_AddAttachmentFile] Unknown error!"; }
        return false;
    }
    
    function Pages_PublishAttachment($values,&$arr,$by_cron=false) {
        global $DB, $MTPS, $User;
        if(IsSet($values['ItemID']) && is_numeric($values['ItemID']) && IsSet($values['PageID']) && is_numeric($values['PageID'])) {
            if(!CanAdmin("pages-add-attachment",$values['PageID'],$response) && !$by_cron) { return false; }
            if(($attachments = $DB->Select("PagesAttachments","`PageID`=".DBText($values['PageID'])." AND `Published`=1",$count,"`SortPos` DESC, `Created` ASC","1")) !== false && $count > 0) {
                $sort_pos = $attachments[0]->SortPos + 1;}
            else {
                $sort_pos = 1;}
            $set = "`Published` = '1', ";
            $set.= "`Title` = '".DBText($values['Title'])."', ";
            $set.= "`SortPos` = '".DBText($sort_pos)."', ";
            if($DB->Update("PagesAttachments",$set,"`ID` = '".DBText($values['ItemID'])."' AND `PageID`=".DBText($values['PageID']),$arr['Response'])) {
                $arr['ReloadToURL'] = AddSlashToEnd($GLOBALS['urlWEB'].$this->GetPagePathByID($values['PageID'],$MTPS->Language));
                $arr['ContentToRefresh'] = $this->WritePageAttachments($values['PageID'],false);
                return true;}}
        else {
            $arr['Response'] = "[Web::Pages_PublishAttachment] Unknown error!";}
        return false;}
    function Pages_DeleteAttachmentFile($values,&$arr) {
        global $DB, $MTPS, $User;
        if(IsSet($values['AttachmentID']) && is_numeric($values['AttachmentID'])) {
            if(($attachments = $DB->Select("PagesAttachments","`ID` = '".DBText($values['AttachmentID'])."'",$count)) !== false && $count > 0) {
                if(!CanAdmin("pages-delete-attachment",$attachments[0]->PageID,$response)) { return false; }
                $file = AddSlashToEnd($GLOBALS['fileWEB']."files/".LngPath()."pages/".$this->GetPagePathByID($attachments[0]->PageID,$MTPS->Language)).$attachments[0]->Filename.".".$attachments[0]->Extension;
                $arr['File'] = $file;
                if(($arr['FileExists'] = file_exists($file))) {
                    $arr['UnlinkResult'] = DeleteFile($file);}
                $DB->Delete("PagesAttachments","`ID`=".DBText($values['AttachmentID']));
                return true;}
            else {
                $arr['Response'] = "[Web::Pages_DeleteAttachmentFile] AttachmentID not found!";}}
        else {
            $arr['Response'] = "[Web::Pages_DeleteAttachmentFile] Unknown error!";}
        return false;}
    function Pages_LoadAttachmentByID($attachment_id) {
        global $DB;
        if(($attachments = $DB->Select("PagesAttachments","`ID`=".DBText($attachment_id)." AND `Published`=1",$count,"","1")) !== false && $count > 0) {
            return $attachments[0];}
        return false;}
    function Pages_RenewAttachmentsSortPos($page_id) {
        global $DB;
        if(($attachments = $DB->Select("PagesAttachments","`PageID`=".DBText($page_id)." AND `Published`=1",$count,"`SortPos` ASC, `Created` ASC")) !== false && $count > 0) {
            for($aa=0; $aa<$count; $aa++) {
                $set = "`SortPos` = '".DBText(($aa+1))."', ";
                $DB->Update("PagesAttachments",$set,"`ID` = '".DBText($attachments[$aa]->ID)."'");}}}
                
    function Pages_MoveAttachment($values,&$arr,$second_pass=false) {
        global $DB, $MTPS, $User;
        $sort_pos = array();
        if(IsSet($values['Move']) && IsSet($values['ItemID']) && is_numeric($values['ItemID']) && IsSet($values['PageID']) && is_numeric($values['PageID'])) {
            if(!CanAdmin("pages-move-attachment",$values['PageID'],$response)) { return false; }
            $move = $values['Move'];
            $page_id = $values['PageID'];
            $attachment_id = $values['ItemID'];
            if(($attachments = $DB->Select("PagesAttachments","`PageID`=".DBText($page_id)." AND `Published`=1",$count,"`SortPos` ASC, `Created` ASC")) !== false && $count > 0) {
                $moved_att_pos = -1;
                for($aa=0; $aa<$count; $aa++) {
                    if($attachments[$aa]->ID == $attachment_id) {
                        $moved_att_pos = $aa;}
                    $n = 'sp'.$attachments[$aa]->SortPos;
                    if(IsSet($sort_pos[$n]) && !$second_pass) {
                        $this->Pages_RenewAttachmentsSortPos($page_id);
                        return $this->Pages_MoveAttachment($values,$arr,true);}
                    else {
                        $sort_pos[$n] = 1;}}
                if($moved_att_pos != -1) {
                    $replacement_pos = $moved_att_pos;
                    if(Settings('PageAttachments_NewestAtBottom',true)) {
                        if($move == 'up' && $moved_att_pos > 0) {
                            $replacement_pos = $moved_att_pos-1;}
                        if($move == 'down' && $moved_att_pos < $count-1) {
                            $replacement_pos = $moved_att_pos+1;}}
                    else {
                        if($move == 'down' && $moved_att_pos > 0) {
                            $replacement_pos = $moved_att_pos-1;}
                        if($move == 'up' && $moved_att_pos < $count-1) {
                            $replacement_pos = $moved_att_pos+1;}}
                    $set = "`SortPos` = '".DBText($attachments[$replacement_pos]->SortPos)."', ";
                    $DB->Update("PagesAttachments",$set,"`ID` = '".DBText($attachments[$moved_att_pos]->ID)."'");
                    $set = "`SortPos` = '".DBText(($attachments[$moved_att_pos]->SortPos))."', ";
                    $DB->Update("PagesAttachments",$set,"`ID` = '".DBText($attachments[$replacement_pos]->ID)."'");
                    $arr['ContentToRefresh'] = $this->WritePageAttachments($page_id,false);
                    return true;}}}
        $arr['Response'] = "[Web::Pages_MoveAttachmentDown] Unknown error!";
        return false;}
    function Pages_DeleteAttachment($values,&$arr) {
        global $DB, $MTPS, $User;
        if(IsSet($values['AttachmentID']) && is_numeric($values['AttachmentID']) && IsSet($values['PageID']) && is_numeric($values['PageID'])) {
            if(!CanAdmin("pages-delete-attachment",$values['PageID'],$response)) { return false; }
            if(($attachments = $DB->Select("PagesAttachments","`ID` = '".DBText($values['AttachmentID'])."' AND `PageID`=".DBText($values['PageID']),$count)) !== false && $count > 0) {
                $file = AddSlashToEnd($GLOBALS['fileWEB']."files/".LngPath()."pages/".$this->GetPagePathByID($attachments[0]->PageID,$MTPS->Language)).$attachments[0]->Filename.".".$attachments[0]->Extension;
                $arr['File'] = $file;
                if(($arr['FileExists'] = file_exists($file))) {
                    $arr['UnlinkResult'] = DeleteFile($file);}
                $DB->Delete("PagesAttachments","`ID` = '".DBText($values['AttachmentID'])."'");
                $arr['ContentToRefresh'] = $this->WritePageAttachments($values['PageID'],false);
                return true;}
            else {
                $arr['Response'] = "[Web::Pages_DeleteAttachment] AttachmentID not found!";}}
        else {
            $arr['Response'] = "[Web::Pages_DeleteAttachment] Unknown error!";}
        return false;}
    function Pages_RenameAttachment($values,&$arr) {
        global $DB;
        if(IsSet($values['Title']) && IsSet($values['AttachmentID']) && is_numeric($values['AttachmentID']) && IsSet($values['PageID']) && is_numeric($values['PageID'])) {
            if(!CanAdmin("pages-rename-attachment",$values['PageID'],$response)) { return false; }
            $set = "`Title` = '".DBText($values['Title'])."', ";
            if($DB->Update("PagesAttachments",$set,"`ID` = '".DBText($values['AttachmentID'])."' AND `PageID`=".DBText($values['PageID']),$arr['Response'])) {
                $arr['ContentToRefresh'] = $this->WritePageAttachments($values['PageID'],false);
                return true;}}
        else {
            $arr['Response'] = "[Web::Pages_RenameAttachment] Unknown error!";}
        return false;}
    function Pages_DeleteAllAttachments($page_id) {
        global $DB, $MTPS;
        if(!CanAdmin("pages-delete-page",$page_id,$response)) { return false; }
        $subpath = $this->GetPagePathByID($page_id,$MTPS->Language);
        if($subpath != "") {
            if(($attachments = $DB->Select("PagesAttachments","`PageID`=".DBText($page_id),$count)) !== false && $count > 0) {
                for($aa=0; $aa<$count; $aa++) {
                    $file = AddSlashToEnd($GLOBALS['fileWEB']."files/".LngPath()."pages/".$subpath).$attachments[$aa]->Filename.".".$attachments[$aa]->Extension;
                    if(@file_exists($file)) {
                        DeleteFile($file);}
                    $DB->Delete("PagesAttachments","`ID` = '".DBText($attachments[$aa]->ID)."'");}}
            DeleteAllFilesInFolder($GLOBALS['fileWEB']."files/".LngPath()."pages/".$subpath);
            @rmdir($GLOBALS['fileWEB']."files/".LngPath()."pages/".$subpath);}}
    function Pages_DeleteAllImages($page_id) {
        global $DB, $MTPS;
        if(!CanAdmin("pages-delete-page",$page_id,$response)) { return false; }
        $subpath = $this->GetPagePathByID($page_id,$MTPS->Language);
        if($subpath != "") {
            if(($images = $DB->Select("PagesImages","`PageID`=".DBText($page_id),$count)) !== false && $count > 0) {
                for($aa=0; $aa<$count; $aa++) {
                    $file = AddSlashToEnd($GLOBALS['fileWEB']."gallery/".LngPath()."pages/".$subpath).$images[$aa]->Filename.".".$images[$aa]->Extension;
                    if(@file_exists($file)) {
                        DeleteFile($file);}
                    $file = AddSlashToEnd($GLOBALS['fileWEB']."gallery/".LngPath()."pages/".$page_id).$images[$aa]->ID.".".$images[$aa]->Extension;
                    if(@file_exists($file)) {
                        DeleteFile($file);}
                    $DB->Delete("PagesImages","`ID` = '".DBText($images[$aa]->ID)."'");}}
            DeleteAllFilesInFolder($GLOBALS['fileWEB']."gallery/".LngPath()."pages/".$subpath);
            DeleteAllFilesInFolder($GLOBALS['fileWEB']."gallery/".LngPath()."pages/".$page_id);
            @rmdir($GLOBALS['fileWEB']."gallery/".LngPath()."pages/".$subpath);
            @rmdir($GLOBALS['fileWEB']."gallery/".LngPath()."pages/".$page_id);}}
    function Pages_AddImage(&$image_id,$page_id,$extension,&$response) {
        global $DB, $MTPS, $User;
        if(!CanAdmin("pages-insert-image",$page_id,$response)) { return false; }
        $response = "";
        if($image_id == 0) {
            if(IsSet($data)) { UnSet($data); }
            $data['PageID'] = $page_id;
            $data['Extension'] = $extension;
            $data['CreatedByUserID'] = GetUserAccountID();
            if(($image_id = $DB->Insert("PagesImages",$data,$response)) !== false) {
                return true;}}
        if($response == "") { $response = "[WEB::Pages_AddImage] Unknown error!"; }
        return false;}
    function GetDepartmentTitleByID($department_id,$language) {
        global $DB;
        if(($departments = $DB->Select("Departments","`ID` = '".DBText($department_id)."'",$departments_count)) !== false && $departments_count > 0) {
            return LngStr($departments[0]->Title,$language);}
        return "";}
    function Contacts_WriteContactListFromUsers() {
        global $DB, $User, $MTPS;
        if((!IsSet($MTPS->Settings['ObjContactsPage']) || $MTPS->Settings['ObjContactsPage'] === null) && IsSet($MTPS->Settings['FncContactsPage']) && $MTPS->Settings['FncContactsPage'] !== null) {
            return call_user_func($MTPS->Settings['FncContactsPage']);}
        else if(IsSet($MTPS->Settings['ObjContactsPage']) && $MTPS->Settings['ObjContactsPage'] !== null) {
            return call_user_func_array(array($MTPS->Settings['ObjContactsPage'],$MTPS->Settings['FncContactsPage']));}
        $str = "";
        if(Settings('CreateContactListFromUsers',true)) {
            if(($departments = $DB->Select("Departments","`ShowInContacts`=1",$departments_count,"`SortPos` ASC, `Title` ASC")) !== false && $departments_count > 0) {
                for($aa=0; $aa<$departments_count; $aa++) {
                    if(($assigns = $DB->Select("UsersDepartmentsAssign","`DepartmentID`=".DBText($departments[$aa]->ID),$assigns_count)) !== false && $assigns_count > 0) {
                        $depstr = "";
                        $written_users_count = 0;
                        $depstr.= "<div class=\"contact_list_from_users_box\">";
                        $depstr.= "<table class=\"contact_list_from_users\" style=\"border-collapse: collapse; border-spacing: 0; \">";
                        $depstr.= "<tr>";
                        $st = "";
                        if($departments[$aa]->FontColor != "") { $st.= "color: ".$departments[$aa]->FontColor.";"; } else { $st.= "color: white;"; }
                        if($departments[$aa]->BackgroundColor != "") { $st.= "background-color: ".$departments[$aa]->BackgroundColor.";"; }
                        $depstr.= "<th colspan=\"3\"><h2 style=\"font-family: calibri; $st\">".LngStr($departments[$aa]->Title)."</h2></th>";
                        $depstr.= "</tr>";
                        $depstr.= "<tr class=\"department\">";
                        $depstr.= "<th class=\"th_name\">Jméno:</th>";
                        $depstr.= "<th class=\"th_function\">Funkce:</th>";
                        $depstr.= "<th class=\"th_telephone\">Telefon:</th>";
                        $depstr.= "</tr>";
                        if(($users = $DB->Select("Users","`IsChiefOfDepartmentID`=".DBText($departments[$aa]->ID)." AND `ShowInContacts`=1 AND `Deactivated`=0",$users_count)) !== false && $users_count > 0) {
                            $written_users_count++;
                            $depstr.= "<tr>";
                            $full_name = WriteFullNameWithAcademicTitles($users[0]->AcademicTitles,$users[0]->FirstName,$users[0]->LastName);
                            $depstr.= "<td class=\"td_name\"><a href=\"".$users[0]->ID."-".PageNameToDirName($users[0]->FirstName.chr(32).$users[0]->LastName)."/\">".$full_name."</a></td>";
                            $depstr.= "<td class=\"td_function\">".LngStr($users[0]->Function)."</td>";
                            $depstr.= "<td class=\"td_telephone\">".WritePhoneNumber($users[0]->Telephone)."</td>";
                            $depstr.= "</tr>";}
                        for($bb=0; $bb<$assigns_count; $bb++) {
                            if(($users = $DB->Select("Users","`ID`=".DBText($assigns[$bb]->UserID)." AND `IsChiefOfDepartmentID`=0 AND `ShowInContacts`=1 AND `Deactivated`=0",$users_count)) !== false && $users_count > 0) {
                                $written_users_count++;
                                $depstr.= "<tr>";
                                if(Settings('EnableAcademicTitles',true)) { $full_name = WriteFullNameWithAcademicTitles($users[0]->AcademicTitles,$users[0]->FirstName,$users[0]->LastName); }
                                else { $full_name = $users[0]->FirstName.chr(32).$users[0]->LastName; }
                                $depstr.= "<td class=\"td_name\"><a href=\"".$users[0]->ID."-".PageNameToDirName($users[0]->FirstName.chr(32).$users[0]->LastName)."/\">".$full_name."</a></td>";
                                $depstr.= "<td class=\"td_function\">".LngStr($users[0]->Function)."</td>";
                                $depstr.= "<td class=\"td_telephone\">".WritePhoneNumber($users[0]->Telephone)."</td>";
                                $depstr.= "</tr>";}}
                        $depstr.= "</table>";
                        $depstr.= "</div>";
                        if($written_users_count > 0) {
                            $str.= $depstr;}}}}}
        return $str;}
    function Contacts_WriteContact($contact_id) {
        global $DB, $User, $MTPS;
        if((!IsSet($MTPS->Settings['ObjContactDetailPage']) || $MTPS->Settings['ObjContactDetailPage'] === null) && IsSet($MTPS->Settings['FncContactDetailPage']) && $MTPS->Settings['FncContactDetailPage'] !== null) {
            return call_user_func($MTPS->Settings['FncContactDetailPage']);}
        else if(IsSet($MTPS->Settings['ObjContactDetailPage']) && $MTPS->Settings['ObjContactDetailPage'] !== null) {
            return call_user_func_array(array($MTPS->Settings['ObjContactDetailPage'],$MTPS->Settings['FncContactDetailPage']));}
        $str = "";
        $path_title = "";
        $navigation_title = "Detail kontaktu";
        if(Settings('CreateContactListFromUsers',true) && ($users = $DB->Select("Users","`ID`=".DBText($contact_id)." AND `Deactivated`=0",$users_count)) !== false && $users_count > 0) {
            $navigation_title = WriteFullNameWithAcademicTitles($users[0]->AcademicTitles,$users[0]->FirstName,$users[0]->LastName);
            $path_title = "-".PageNameToDirName($navigation_title)."/";
            $str.= "<h1>".$navigation_title."</h1>";
            $str.= "<h2>".LngStr($users[0]->Function)."</h2>";
            $str.= "<table class=\"contact-detail-table\">";
            if(Settings('EnableDepartments',true) && ($depts = $DB->Select("Departments","",$depts_count)) !== false && $depts_count > 0) {
                $departments = "";
                for($aa=0; $aa<$depts_count; $aa++) {
                    if($depts[$aa]->ShowInContacts && $User->UserIsMemberOfDepartmentID($users[0]->ID,$depts[$aa]->ID)) {
                        if(LngStr($depts[$aa]->Title) != "Tajemnice úřadu" && LngStr($depts[$aa]->Title) != "Starosta a místostarostové") {
                            if($departments != "") { $departments.= "<br />"; }
                            $departments.= LngStr($depts[$aa]->Title);
                            if($depts[$aa]->ID == $users[0]->IsChiefOfDepartmentID) {
                                $departments.= ", vedoucí";}}}}
                if($departments != "") {
                    $str.= "<tr><th>".Lng('Department').":</th><td>";
                    $str.= $departments."</td></tr>";}}
            $str.= "<tr><th>".Lng('Email').":</th><td><a href=\"mailto:".$users[0]->Email."\">".$users[0]->Email."</a></td></tr>";
            $str.= "<tr><th>".Lng('Telephone').":</th><td>".LngStr(WritePhoneNumber($users[0]->Telephone))."</td></tr>";
            if(Settings('EnableBuildingsAndLocations',true) && ($building = LoadBuildingByID($users[0]->BuildingID)) !== false) {
                if($users[0]->Level != "") { $level = ", ".$users[0]->Level.". patro"; } else { $level = ""; }
                if($users[0]->Doors != "") { $doors = ", dveře č. ".$users[0]->Doors; } else { $doors = ""; }
                $str.= "<tr><th>".Lng('Building').":</th><td>".LngStr($building->Title).$doors.$level."</td></tr>";}
            $str.= "</table>";}
        else {
            $str.= "<h1>Detail kontaktu</h1>";
            $str.= "<h2>Kontakt nenalezen.</h2>";}
        $str.= "<p>&larr;&nbsp;<a href=\"".$GLOBALS['urlWEB']."mestsky-urad/kontakty/\">Zpět na telefonní seznam úřadu</a></p>";
        if(($page = $this->LoadPageByType(5)) !== false) {
            if(($path = $this->GetPagePathByID($page->ID,$MTPS->Language)) !== "") {
                AddNavigation($navigation_title,$GLOBALS['urlWEB'].$path.$contact_id.$path_title);}}
        return $str;}
    function WriteAdministrationIcons() {
        global $MTPS, $User;
        $str = "";
        $count = 0;
        $arr = array();
        if(Settings('EnableGallery',true) && CanAdmin('gallery')) {
            $arr[$count]['Caption'] = "Galerie";
            $arr[$count]['URL'] = $GLOBALS['urlADMIN'].Lng('urlGALLERY')."/";
            $arr[$count]['Background'] = $GLOBALS['urlIMG']."admin/gallery.png";
            $count++;}
        if(defined("zmrm") && ($User->Account->AccountType == 1 || $User->Account->AccountType == 2)) {
            if(IsSet($MTPS->IntranetIconCount)) {
                for($aa=0; $aa<$MTPS->IntranetIconCount; $aa++) {
                    if(IsSet($MTPS->IntranetIcon[$aa])) {
                        $arr[$count]['Caption'] = $MTPS->IntranetIcon[$aa]['Title'];
                        $arr[$count]['URL'] = $MTPS->IntranetIcon[$aa]['URL'];
                        $arr[$count]['Background'] = $MTPS->IntranetIcon[$aa]['Background'];
                        $count++;}}}}
        $arr[$count]['Caption'] = "Správa uživatelů";
        $arr[$count]['URL'] = $GLOBALS['urlADMIN'].Lng('urlUSERS')."/";
        $arr[$count]['Background'] = $GLOBALS['urlIMG']."admin/users.png";
        $count++;
        $arr[$count]['Caption'] = "Opustit administraci";
        $arr[$count]['URL'] = $GLOBALS['urlWEB'];
        $arr[$count]['Background'] = $GLOBALS['urlIMG']."admin/exit.png";
        $count++;
        for($aa=0; $aa<$count; $aa++) {
            $st = "";
            if(IsSet($arr[$aa]['Background'])) { $st = " style=\"background: rgb(245,245,245); background-image: url('".$arr[$aa]['Background']."'); background-position: center .5em; background-size: auto 65%; background-repeat: no-repeat; \""; }
            $str.= "<a href=\"".$arr[$aa]['URL']."\" class=\"admin_icon\"$st>";
            $str.= "<span>";
            $str.= $arr[$aa]['Caption'];
            $str.= "</span>";
            $str.= "</a>";}
        return $str;}
    function PagePosInWebTree($page) {
        global $MTPS;
        for($aa=0; $aa<count($MTPS->WebTree); $aa++) {
            if($MTPS->WebTree[$aa]->id == $page->ID) {
                return $aa;}}
        return -1;}
    function GetWebTreePageUrl($page) {
        global $MTPS;
        for($aa=0; $aa<$MTPS->WebURLsCount; $aa++) {
            if($MTPS->WebURLs[$aa]->PageID == $page->ID) {
                return $MTPS->WebURLs[$aa]->URL;}}
        return "/";}
    function AddPageToWebTree($page) {
        global $MTPS;
        $pos = $this->PagePosInWebTree($page);
        if($pos == -1) {
            $pos = count($MTPS->WebTree);
            $MTPS->WebTree[$pos] = new stdClass();}
        if($page->Changed > $MTPS->WebTreeLastUpdate) { $MTPS->WebTreeLastUpdate = $page->Changed; }
        $MTPS->WebTree[$pos]->id = $page->ID;
        $MTPS->WebTree[$pos]->parentId = $page->ParentID;
        $MTPS->WebTree[$pos]->name = $page->Name;
        $MTPS->WebTree[$pos]->title = LngStr($page->Title);
        $MTPS->WebTree[$pos]->sortPos = $page->SortPos;
        $MTPS->WebTree[$pos]->changed = $page->Changed;
        $MTPS->WebTree[$pos]->url = $this->GetWebTreePageUrl($page);
        return $pos;}
    function LoadWebTree() {
        global $MTPS, $DB;
        if(Settings('EnablePages')) {
            $now = Time();
            if($MTPS->WebTreeTime < $now - 5 || $MTPS->WebTree === null) {
                if(($pages = $DB->Select("Pages","`ParentID`>=0",$pages_count,"`ParentID` ASC, `SortPos` ASC")) !== false && $pages_count > 0) {
                    if(($MTPS->WebURLs = $DB->Select("PagesURLs","`PageID`>0 AND `Language`='".DBText($MTPS->Language)."'",$MTPS->WebURLsCount)) !== false && $MTPS->WebURLsCount > 0) {
                        $MTPS->WebTreeLastUpdate = 0;
                        $MTPS->WebTreeTime = $now;
                        $MTPS->WebTree = array();
                        for($aa=0; $aa<$pages_count; $aa++) {
                            $this->AddPageToWebTree($pages[$aa]);}}
                    else {}}
                else {}}}}
    function ajaxLog($vals,&$arr) {
        if(IsSet($vals['text'])) {
            WriteLog($vals['text']);
            return true;}
        return false;}
    function ajaxLoadWebTree($vals,&$arr) {
        global $MTPS;
        if(IsSet($vals['lastUpdate']) && IsSet($vals['lastCount']) && IsSet($vals['lng'])) {
            $this->LoadWebTree();
            $count = count($MTPS->WebTree);
            if($vals['lastUpdate'] != $MTPS->WebTreeLastUpdate || $vals['lastCount'] != $count || $vals['lng'] != $MTPS->Language) {
                $arr['items'] = $MTPS->WebTree;}
            $arr['count'] = $count;
            $arr['lng'] = $MTPS->Language;
            $arr['lastUpdate'] = $MTPS->WebTreeLastUpdate;
            return true;}
        return false;}
    function WritePageMenu($parent_id,$write_leading_link=true,$enable_ajax_pageload=false,$treepos=0,$pages=array(),$pages_count=0,$collapsed=false,$first_parent_id=0,$first_menu_only=false) {
        global $MTPS, $DB;
        $str = "";
        $real_count = 0;
        $menu_title_first = "";
        if($treepos == 0) {
            $menu_title_first = "_first";
            $first_parent_id = $parent_id;
            if(($pages = $DB->SelectTree("Pages","",$first_parent_id,0,$pages_count,"`SortPos` ASC, `Created` ASC")) !== false && $pages_count > 0) {
                for($aa=0; $aa<$pages_count; $aa++) {
                    $pages[$aa]->Collapsed = true;
                    if($pages[$aa]->ID == $MTPS->PageID) { $pages[$aa]->Collapsed = false; }
                    for($bb=0; $bb<$MTPS->PageParentsCount; $bb++) {
                        if($MTPS->PageParents[$bb]->ID == $pages[$aa]->ID) { $pages[$aa]->Collapsed = false; }}}}
            if($write_leading_link) {
                $cookie = "";
                for($aa=0; $aa<$pages_count; $aa++) {
                    if(!$pages[$aa]->Collapsed) { $cookie.= $pages[$aa]->ID.","; }}
/*                SetCookie("ExpandedMenuItems".$first_parent_id,$cookie,0,'/; samesite=strict');*/
                SetCookie("ExpandedMenuItems".$first_parent_id,$cookie,
                [
                    'expires' => Time()+90*24*60*60,
                    'path' => '/',
                    'domain' => '',
                    'secure' => true,
                    'httponly' => true,
                    'samesite' =>'strict',
                ]);


            }}
        if($pages_count > 0) {
            if($collapsed) { $st = " style=\"display: none;\""; } else { $st = ""; }
            if($treepos == 0) { $str.= "<ul id=\"PageMenu".$first_parent_id."\"$st>"; } else { $str.= "<ul$st>"; }
            if($treepos == 0 && $write_leading_link) {
                if(($leading_page = $DB->Select("Pages","`ID`=".DBText($first_parent_id),$lp_count)) !== false && $lp_count > 0) {
                    $url = $GLOBALS['urlWEB'].$this->GetPagePathByID($leading_page[0]->ID,$MTPS->Language);
                    $str.= "<li><a href=\"".$url."\" class=\"menu_title$menu_title_first\">".LngStr($leading_page[0]->Title)."</a></li>";
                    $menu_title_first = "";}}
            for($aa=0; $aa<$pages_count; $aa++) {
                if($pages[$aa]->ParentID == $parent_id) {
                    $real_count++;
                    $onclick = "";
                    if($this->PagesTreeNodeHasChild($pages[$aa]->ID,$pages,$pages_count)) {
                        if($pages[$aa]->Collapsed) { $link_class = 'collapsed'; }
                        else { $link_class = 'expanded'; }}
                    else {
                        $link_class = 'empty';}
                    if($pages[$aa]->ID == $MTPS->PageID) { $link_class.= " selected"; }
                    $str.= "<li>";
                    $url = "";
                    if($pages[$aa]->Type == 100) {
                        if(($new_page = $this->LoadPageByID($pages[$aa]->RedirectTo)) !== false) {
                            $redirect_to = $this->GetPagePathByID($new_page->ID,$MTPS->Language);
                            $url = $GLOBALS['urlWEB'].$redirect_to;}}
                    if($url == "") {
                        $url = $GLOBALS['urlWEB'].$this->GetPagePathByID($pages[$aa]->ID,$MTPS->Language);}
                    $str.= "<a href=\"".$url."\" title=\"".LngStr($pages[$aa]->Title)."\""; if($onclick != "") { $str.= " onclick=\"".$onclick."\""; } $str.= " class=\"".$link_class."\" style=\"padding-left: ".$treepos."em; \"><img class=\"imgplus\" src=\"".$GLOBALS['urlIMG']."triangle-plus.png\" alt=\"\" /><img class=\"imgminus\" src=\"".$GLOBALS['urlIMG']."triangle-minus.png\" alt=\"\" /><img class=\"imgempty\" src=\"".$GLOBALS['urlIMG']."ball-silver.png\" alt=\"\" />".LngStr($pages[$aa]->Title)."</a>";
                    if(!$first_menu_only) {
                        $str.= $this->WritePageMenu($pages[$aa]->ID,false,$enable_ajax_pageload,$treepos+1,$pages,$pages_count,$pages[$aa]->Collapsed,$first_parent_id);}
                    $str.= "</li>";}}
            $str.= "</ul>";}
        if($real_count == 0) { return ""; }
        return $str;}
    public function PagesTreeNodeHasChild($node_id,$pages,$count) {
        for($aa=0; $aa<$count; $aa++) {
            if($pages[$aa]->ParentID == $node_id) { return true; }}
        return false;}
    function PrepareLayoutSettings($layout_name) {
        global $MTPS, $DB, $User;
        $this->Part['OGPageURL'] = $MTPS->URL;

        if(IsSet($MTPS->WebDescription)) { $this->Part['WebDescription'] = $MTPS->WebDescription; }

        if(IsSet($MTPS->OGPageID) && $MTPS->OGPageID != "") { $this->Part['OGPageID'] = $MTPS->OGPageID; }
        if(IsSet($MTPS->FBAdmins) && $MTPS->FBAdmins != "") { $this->Part['FBAdmins'] = $MTPS->FBAdmins; }
        if(IsSet($MTPS->OGPageTitle) && $MTPS->OGPageTitle != "") { $this->Part['OGPageTitle'] = $MTPS->OGPageTitle; } else { $this->Part['OGPageTitle'] = $MTPS->WebName; }
        if(IsSet($MTPS->OGPageTitle) && $MTPS->OGPageTitle != "") { $this->Part['OGPageTitle'] = $MTPS->OGPageTitle; } else { $this->Part['OGPageTitle'] = $MTPS->WebName; }

        if(IsSet($MTPS->OGPageImage) && $MTPS->OGPageImage != "") { $this->Part['OGPageImage'] = $GLOBALS['urlWEB'].$MTPS->OGPageImage; } else { $this->Part['OGPageImage'] = $GLOBALS['imgWEB']."pagelogo.png"; }
        if(IsSet($MTPS->OGPageImageType) && $MTPS->OGPageImageType != "") { $this->Part['OGPageImageType'] = $GLOBALS['urlWEB'].$MTPS->OGPageImageType; } else { $this->Part['OGPageImageType'] = $GLOBALS['imgWEB']."pagelogo.png"; }
        if(IsSet($MTPS->OGPageImageWidth) && $MTPS->OGPageImageWidth != "") { $this->Part['OGPageImageWidth'] = $GLOBALS['urlWEB'].$MTPS->OGPageImageWidth; } else { $this->Part['OGPageImageWidth'] = $GLOBALS['imgWEB']."pagelogo.png"; }
        if(IsSet($MTPS->OGPageImageHeight) && $MTPS->OGPageImageHeight != "") { $this->Part['OGPageImageHeight'] = $GLOBALS['urlWEB'].$MTPS->OGPageImageHeight; } else { $this->Part['OGPageImageHeight'] = $GLOBALS['imgWEB']."pagelogo.png"; }
        if(IsSet($MTPS->OGPageDescription) && $MTPS->OGPageDescription != "") { $this->Part['OGPageDescription'] = $MTPS->OGPageDescription; }

        if(IsSet($MTPS->OGType) && $MTPS->OGType != "") { $this->Part['OGType'] = $MTPS->OGType; } else { $this->Part['OGType'] = $MTPS->WebName; }
        if(IsSet($MTPS->OGArticlePublisher) && $MTPS->OGArticlePublisher != "") { $this->Part['OGArticlePublisher'] = $MTPS->OGArticlePublisher; } else { $this->Part['OGArticlePublisher'] = $MTPS->WebName; }
        if(IsSet($MTPS->OGArticleAuthor) && $MTPS->OGArticleAuthor != "") { $this->Part['OGArticleAuthor'] = $MTPS->OGArticleAuthor; } else { $this->Part['OGArticleAuthor'] = $MTPS->WebName; }

    }

    function WriteWeb() {
//        error_log("WriteWeb");
        global $MTPS;
        if($MTPS->WriteNothing) {
            return "";
        }

        $layout = "";
        if(!$this->IsScript) {
//            error_log("WriteWeb 1 Layout " .$this->Layout);

            if($this->Layout == "") {
                $this->Layout = $MTPS->DefaultLayout;
            }
            $this->PrepareLayoutSettings($this->Layout);
            $layout = $this->LoadLayout($this->Layout);
            if(IsSet($MTPS->PageParents[1])) { $page_parent_id = $MTPS->PageParents[1]->ID; }
            else if(IsSet($MTPS->PageParents[0])) { $page_parent_id = $MTPS->PageParents[0]->ID; }
            else { $page_parent_id = 0; }
            foreach($_COOKIE as $name => $val) {
                if(strpos($name,"ExpandedMenuItems") !== false && $name != "ExpandedMenuItems".$page_parent_id) {
                    SetCookie($name,"",
                    [
                        'expires' => Time()+90*24*60*60,
                        'path' => '/',
                        'domain' => '',
                        'secure' => true,
                        'httponly' => true,
                        'samesite' =>'strict',
                    ]);
                }
            }
            $layout = $this->FillLayout($layout);
            $layout = @str_replace("<img src=\"","<img src=\"".$GLOBALS['urlIMG']."1px.gif\" data-src=\"",$layout);
        } else {

            $layout = trm("<!doctype html>");
            $layout.= trm("<html>");
            $layout.= trm("<head lang=\"<PagePart:Language:>\">");
            $layout.= trm("<meta http-equiv=\"content-type\" content=\"text/html; charset=<PagePart:Charset:>\" />");
            if(IsSet($MTPS->Favicon) && $MTPS->Favicon != "") { $layout.= trm("<link rel=\"shortcut icon\" type=\"image/x-icon\" href=\"".$MTPS->Favicon."\" />"); }
            $layout.= trm("<title><PagePart:Title:></title>");
            $layout.= trm("</head>");
            $layout.= trm("<body style=\"font-family:monospace;font-size:11px;line-height:150%\"><PagePart:Body:></body></html>");
            $layout = $this->FillLayout($layout);
        }
        $layout = str_replace($GLOBALS['imgWEB'],"/",$layout);
        $layout = str_replace("<meta property=\"og:url\" content=\"/","<meta property=\"og:url\" content=\"".$GLOBALS['imgWEB'],$layout);
        $layout = str_replace("<meta property=\"og:image\" content=\"//","<meta property=\"og:image\" content=\"".$GLOBALS['imgWEB'],$layout);
        $layout = str_replace("<meta property=\"og:image\" content=\"/","<meta property=\"og:image\" content=\"".$GLOBALS['imgWEB'],$layout);
        return $layout;
    }
    public function LoadLayout($layout_name) {
        global $MTPS, $DB;

        switch($layout_name) {

            case "blank":
                $layout = $this->LoadBlankLayout($MTPS->ClientLayout);
                break;

            /*            case "user":
                            $layout = WEB_LoadUserLayout($MTPS->ClientLayout);
                            break;
                        case "admin":
                            $layout = "<!doctype html>
            <head lang=\"<PagePart:Language:>\">
            <meta http-equiv=\"content-type\" content=\"text/html; charset=<PagePart:Charset:>\" />
            <PagePart:Favicon:>
            <PageIf:def_admin:><link rel=\"stylesheet\" type=\"text/css\" href=\"<PagePart:urlCSS:>admin<PagePart:MTPSReleaseTime:>.css\" /></PageIf>
            <PageIf:!def_mtps-dialogs-editor-supertext-windows:><link rel=\"stylesheet\" type=\"text/css\" href=\"<PagePart:urlCSS:>editor<PagePart:MTPSReleaseTime:>.css\" /></PageIf>
            <PageIf:!def_mtps-dialogs-editor-supertext-windows:><link rel=\"stylesheet\" type=\"text/css\" href=\"<PagePart:urlCSS:>supertext<PagePart:MTPSReleaseTime:>.css\" /></PageIf>
            <PageIf:!def_mtps-dialogs-editor-supertext-windows:><link rel=\"stylesheet\" type=\"text/css\" href=\"<PagePart:urlCSS:>dialogs<PagePart:MTPSReleaseTime:>.css\" /></PageIf>
            <PageIf:def_mtps-dialogs-editor-supertext-windows:><link rel=\"stylesheet\" type=\"text/css\" href=\"<PagePart:urlCSS:>mtps-dialogs-editor-supertext-windows<PagePart:MTPSReleaseTime:>.css\" /></PageIf>
            <PageIf:def_mtps-dialogs-editor-upclick-supertext-windows:><script src=\"<PagePart:urlJS:>mtps-dialogs-editor-upclick-supertext-windows<PagePart:MTPSReleaseTime:>.js\"></script></PageIf>
            <PageIf:!def_mtps-dialogs-editor-upclick-supertext-windows:><script src=\"<PagePart:urlJS:>mtps<PagePart:MTPSReleaseTime:>.js\"></script></PageIf>
            <PageIf:!def_mtps-dialogs-editor-upclick-supertext-windows:><script src=\"<PagePart:urlJS:>dialogs<PagePart:MTPSReleaseTime:>.js\"></script></PageIf>
            <PageIf:!def_mtps-dialogs-editor-upclick-supertext-windows:><script src=\"<PagePart:urlJS:>editor<PagePart:MTPSReleaseTime:>.js\"></script></PageIf>
            <PageIf:!def_mtps-dialogs-editor-upclick-supertext-windows:><script src=\"<PagePart:urlJS:>upclick<PagePart:MTPSReleaseTime:>.js\"></script></PageIf>
            <PageIf:!def_mtps-dialogs-editor-upclick-supertext-windows:><script src=\"<PagePart:urlJS:>supertext<PagePart:MTPSReleaseTime:>.js\"></script></PageIf>
            <PageIf:def_admin:><script src=\"<PagePart:urlJS:>admin<PagePart:MTPSReleaseTime:>.js?url=<PagePart:urlTHIS_encoded:>\"></script></PageIf>
            <PageIf:def_admin:><script src=\"<PagePart:urlJS:>news<PagePart:MTPSReleaseTime:>.js\"></script></PageIf>
            <script src=\"<PagePart:urlJS:>admin.pages<PagePart:MTPSReleaseTime:>.js\"></script>
            <script src=\"<PagePart:urlJS:>admin.officialboard<PagePart:MTPSReleaseTime:>.js\"></script>
            <script src=\"<PagePart:urlJS:>gallery<PagePart:MTPSReleaseTime:>.js\"></script>
            <script src=\"<PagePart:urlJS:>admin.zmrm<PagePart:MTPSReleaseTime:>.js\"></script>
            <title><PagePart:Title:></title>
            </head>
            <body lang=\"<PagePart:Language:>\" onload=\"mtpsLoadPageImages();_init();\" onmouseup=\"_mouseup();\" onkeydown=\"mtpsKeydown(event);\" onresize=\"_resize();\">
            <div id=\"Header\"><div class=\"box\"><div class=\"inner\">
            <div class=\"left\"><PagePart:ADMIN_HeaderLeft:></div>
            <div class=\"right\"><PagePart:ADMIN_HeaderRight:></div>
            </div></div>
            <div class=\"clear\"></div>
            </div>
            <div id=\"Navigation\"><div class=\"box\"><div class=\"inner\">
            <PagePart:Navigation:>
            </div></div>
            </div>
            <div id=\"Desk\"><div class=\"box\"><div class=\"inner\">
            <div id=\"Content\">
            <PagePart:ADMIN_ContentLayout:>
            </div>
            </div></div>
            </div>
            <div id=\"Footer\"><div class=\"box\"><div class=\"inner\">
            <div class=\"left\"><PagePart:ADMIN_FooterLeft:></div>
            <div class=\"right\">MTPS2 &copy; <a href=\"http://www.davidkorinek.cz\" target=\"_blank\">David Kořínek</a> 2013 - 2019</div>
            </div></div>
            <div class=\"clear\"></div>
            </div>
            <div id=\"Test\"></div><div id=\"mnuFirst\"></div></body>
            </html>
            ";
                            break;*/


            default:
//                error_log("LoadLayout layout_name " .$layout_name);

                $file = $GLOBALS['fileTEMPLATES'].$layout_name."/".$layout_name.".layout";

//                error_log("LoadLayout file " .$file);


                if(@file_exists($file)) {
                    $layout = @file_get_contents($file);
                } else {
                    $layout = $this->LoadDefaultLayout($MTPS->ClientLayout);
                }
                break;
        }
//        error_log("LoadLayout 9 ".$layout);

        return $layout;
    }
    function GetLanguageData($language,&$arr) {
        global $MTPS, $User, $TEXTS;
        $arr = array();
        foreach($TEXTS as $key => $val) {
            if(IsSet($val[$language])) { $arr[$key] = $val[$language]; $arr['Status'] = true; }}
        return JsonEncode($arr);
    }
    function ClearPart($part) {
        $this->Part[$part] = "";
    }
    function AddPart($part,$content,$type="",$wrap=true,$class="",$style="") {
        if(!IsSet($this->Part[$part])) { $this->Part[$part] = ""; }
        if($class != "") { $class = ' class="'.$class.'"'; }
        if($style != "") { $style = ' style="'.$style.'"'; }
        if($type == "") { $this->Part[$part].= $content; }
        if($type == "line") { $this->Part[$part].= $content."<br />"; }
        if($type == "p") { $this->Part[$part].= "<p$class$style>".$content."</p>"; }
        if($type == "span") { $this->Part[$part].= "<span$class$style>".$content."</span>"; }
        if($type == "h1") { $this->Part[$part].= "<h1$class$style>".$content."</h1>"; }
        if($type == "h2") { $this->Part[$part].= "<h2$class$style>".$content."</h2>"; }
        if($type == "h3") { $this->Part[$part].= "<h3$class$style>".$content."</h3>"; }
        if($wrap) { $this->Part[$part].= "\n"; }
    }
    function ReplacePart($part,$content,$layout) {
        $content = rtrim($content);
        if(function_exists($content)) {
            $layout = @str_replace("<PagePart:$part:>",call_user_func($content),$layout);}
        else {
            $layout = @str_replace("<PagePart:$part:>",$content,$layout);}
        return $layout;
    }
    function CreatePageTitle() {
        global $MTPS;
        $pgtitle = "";
        if($MTPS->Title == "" || $MTPS->IsIndexPage) { $pgtitle = $MTPS->EndTitle; }
        else {
            if($MTPS->EndTitle != "") { $pgtitle = $MTPS->Title.chr(32).$MTPS->TitleSep.chr(32).$MTPS->EndTitle; }
            else { $pgtitle = $MTPS->Title; }}
        $pgtitle = @str_replace("Hlavní stránka - ","",$pgtitle);
        return $pgtitle;
    }
    
    function FillLayout($layout,$pass2=false) {
//        error_log("FillLayout ");
        global $MTPS, $User;
        $start = 0;
        $posX = 0;
        while(($plugin = FindBetween($layout,"&lt;PagePart:",":&gt;",$start,$posX)) !== false) {
            $layout = str_replace("&lt;PagePart:".$plugin.":&gt;","<PagePart:".$plugin.":>",$layout);
        }
        $layout = $this->ReplacePart("mtpsCSS",$this->mtpsCSS(),$layout);
        $layout = $this->ReplacePart("mtpsJS",$this->mtpsJS(),$layout);
        $layout = $this->FillSubLayouts($layout);

//        $layout = $this->PIM_SpecialLayoutFill($layout);
//        $layout = $this->ADMIN_SpecialLayoutFill($layout);
        $layout = $this->FillPageIfs($layout);
        $layout = $this->FillPageMenus($layout);
        if(IsSet($MTPS->Favicon) && $MTPS->Favicon != "") { $layout = $this->ReplacePart("Favicon","<link rel=\"shortcut icon\" type=\"image/x-icon\" href=\"".$MTPS->Favicon."\" />",$layout); }
        $layout = $this->ReplacePart("MTPSReleaseTime",$GLOBALS['MTPSReleaseTime'],$layout);
        $layout = $this->ReplacePart("ActualYear",Date("Y"),$layout);
        $layout = $this->ReplacePart("Language",$MTPS->Language,$layout);
        $layout = $this->ReplacePart("Charset",$MTPS->Charset,$layout);
        $layout = $this->ReplacePart("urlIMG",$GLOBALS['urlIMG'],$layout);
        $layout = $this->ReplacePart("urlWEB",$GLOBALS['urlWEB'],$layout);
        $layout = $this->ReplacePart("urlNEWS",$GLOBALS['urlWEB'].Lng('urlNEWS'),$layout);
        $layout = $this->ReplacePart("urlADMIN",$GLOBALS['urlADMIN'],$layout);
        $layout = $this->ReplacePart("urlCSS",$GLOBALS['urlCSS'],$layout);
        $layout = $this->ReplacePart("urlJS",$GLOBALS['urlJS'],$layout);
        $layout = $this->ReplacePart("urlTEMPLATES",$GLOBALS['urlTEMPLATES'],$layout);
        $layout = $this->ReplacePart("urlKWIMODULES",$GLOBALS['urlTEMPLATES'].$MTPS->DefaultLayout."/modules/",$layout);
        $layout = $this->ReplacePart("urlTHISTEMPLATE",$GLOBALS['urlTEMPLATES'].$MTPS->DefaultLayout."/",$layout);
        $layout = $this->ReplacePart("urlBLOG",$GLOBALS['urlBLOG'],$layout);
        $layout = $this->ReplacePart("urlPIM",$GLOBALS['urlPIM'],$layout);
        $layout = $this->ReplacePart("imgWEB",$GLOBALS['imgWEB'],$layout);
        $layout = $this->ReplacePart("urlMTPS",$GLOBALS['urlMTPS'],$layout);
        $layout = $this->ReplacePart("urlDEFAULT",$GLOBALS['urlWEB'],$layout);
        $layout = $this->ReplacePart("urlTHIS_encoded",urlencode($MTPS->URL),$layout);
        $layout = $this->ReplacePart("urlUSER",Lng('urlUSER')."/",$layout);
        $layout = $this->ReplacePart("urlTERMS",$GLOBALS['urlTERMS'],$layout);
        $layout = $this->ReplacePart("urlTASKS",Lng('urlTASKS')."/",$layout);
        $layout = $this->ReplacePart("urlINVITEFRIENDS",Lng('urlINVITEFRIENDS')."/",$layout);
        $layout = $this->ReplacePart("TodayIsFullDate",$this->WriteTodayIsFullDate(),$layout);
        $layout = $this->ReplacePart("TodaysName",$this->WriteTodaysName(),$layout);
        $layout = $this->ReplacePart("BG_or_BGM",$MTPS->ClientLayout==1?"bg":"bgm",$layout);
        $layout = $this->ReplacePart("Random_1to17",sprintf("%03d",Rand(1,17)),$layout);
        $layout = $this->ReplacePart("Random_1to39",sprintf("%03d",Rand(1,39)),$layout);
        $layout = $this->ReplacePart("FromMobileApp",BoolToInt($GLOBALS['FromMobileApp']),$layout);
        $layout = $this->ReplacePart("MobileAppVersion",$GLOBALS['MobileAppVersion'],$layout);
        $layout = $this->ReplacePart("IndexCssPrefix",$this->indexCssPrefix(),$layout);
        if($MTPS->Page !== false) {
            $layout = $this->ReplacePart("PageTitle",LngStr($MTPS->Page->Title),$layout);}
        if(Settings('EnableCalendar')) {
            $layout = $this->ReplacePart("EventCalendarSmall",WEB_Calendar_WriteSmallCalendar(),$layout);}
        $layout = $this->ReplacePart("SpravceCasuCalendarBoxSmall",$this->WriteSpravceCasuCalendarBox("small"),$layout);
        $layout = $this->ReplacePart("SpravceCasuCalendarBoxDoubleLineWithPictures",$this->WriteSpravceCasuCalendarBox("double-line-pictures"),$layout);
        $layout = $this->ReplacePart("SpravceCasuCalendarBoxDoubleLineWithPicturesNoStyle",$this->WriteSpravceCasuCalendarBox("double-line-pictures-no-style"),$layout);
        if(Settings('EnableLocalTV')) { $layout = $this->ReplacePart("LocalTVSmall",LocalTV_WriteSmallPageBox(),$layout); }
        $layout = $this->ReplacePart("NewNavigation",$this->ReplaceNewNavigationPart(),$layout);
        if(IsSet($MTPS->ReplaceParts)) {
            foreach($MTPS->ReplaceParts as $key => $val) {
                if(IsSet($MTPS->ReplaceParts[$key]->Name) && IsSet($MTPS->ReplaceParts[$key]->Fnc)) {
                    $layout = $this->ReplacePart($val->Name,call_user_func($val->Name),$layout);}
            }
        }
        if(!$pass2) {
            if(Settings('EnableGallery')) {
                $layout = $this->ReplacePart("RandomImageFromGallery15em",WEB_Gallery_WriteRandomImage(15*$MTPS->EM),$layout);}
            $layout = $this->ReplacePart("lngVer",$GLOBALS['LNG']->ver(),$layout);
            if(defined("odoprag.cz")) {
                $layout = $this->ReplacePart("OdopragCz_MainMenu",$this->OdopragCz_MainMenu(),$layout);
                $layout = $this->ReplacePart("OdopragCz_Calendar",$this->OdopragCz_Calculace(),$layout);
                $layout = $this->ReplacePart("ContactForm",$this->OdopragCz_Calculace(),$layout);
            }
        }
        if(!$MTPS->HTTPS && IsSet($MTPS->StatsCodes) && $MTPS->StatsCodes != "") { $layout = $this->ReplacePart("StatsCodes",$MTPS->StatsCodes,$layout); }
        if($MTPS->HTTPS && IsSet($MTPS->StatsCodesSSL) && $MTPS->StatsCodesSSL != "") { $layout = $this->ReplacePart("StatsCodes",$MTPS->StatsCodesSSL,$layout); }
        if(Settings('EnablePages')) {
            $page_menu = "";
            if(IsSet($MTPS->PageParents[1])) {
                $page_menu = $this->WritePageMenu($MTPS->PageParents[1]->ID,true,false);
                if($page_menu == "" && IsSet($MTPS->PageParents[0])) {
                    $page_menu = $this->WritePageMenu($MTPS->PageParents[0]->ID,true,false);}
            } else {
                $page_menu = $this->WritePageMenu(1,true,false);
            }
            $layout = $this->ReplacePart("PageMenu1",$page_menu,$layout);
        }
        $pgtitle = $this->CreatePageTitle();
        $layout = $this->ReplacePart("Title",$pgtitle,$layout);
        if(!IsSet($MTPS->Refresh) || $MTPS->Refresh <= 0) { $refresh = ""; } else { $refresh = "<meta http-equiv='refresh' content='".$MTPS->Refresh."; url=".$MTPS->URL."'>"; }
        $layout = $this->ReplacePart("Refresh",$refresh,$layout);
        if(strpos($layout,"<PagePart:Reports:>") === false) {
            if(IsSet($this->Part['Body'])) {
                $this->Part['Body'] = WriteReports().$this->Part['Body'];
            } else {
                pBody(WriteReports());
            }
        } else {
            $layout = $this->ReplacePart("Reports",WriteReports(),$layout);
        }
        if(is_array($this->Part)) {
            foreach($this->Part as $key => $val) {
                if($key == "Body") {
                    $layout = $this->ReplacePart($key,WriteReports().$val,$layout);
                } else {
                    $layout = $this->ReplacePart($key,$val,$layout);
                }
            }
        }
        $layout = $this->replaceLngParts($layout);

        if($pass2) {
            $layout = $this->FillURLs($layout);
            $layout = $this->ReplaceFunctionParts($layout);
            $layout = $this->DeleteEmptyParts($layout);
            $layout = $this->TrimLayout($layout);}
        else {
            $layout = $this->FillLayout($layout,true);}
        return $layout;
    }
    
    public function ReplaceNewNavigationPart() {
        global $MTPS;
        $str = "";
        if(IsSet($this->Part['Navigation']) && $this->Part['Navigation'] != "") {
            if(!$MTPS->IsIndexPage) {
                $str = "<div class=\"navigation\"><div>".ln(107).": </div><div id=\"Navigation\">".$this->Part['Navigation']."</div></div>";}}
        return $str;}
    public function ADMIN_SpecialLayoutFill($layout) {
        global $MTPS, $DB, $User, $Web;
        $content = "";
        if(IsWebSection('admin')) { $class = "active"; } else { $class = ""; }
        $content.= SmartLink(Lng('Administration'),$GLOBALS['urlADMIN'],"","",$class);
        if(Settings('EnableArticles',true)) {
            if(IsWebSection('admin/articles')) { $class = "active"; } else { $class = ""; }
            $content.= SmartLink(Lng('Articles'),$GLOBALS['urlARTICLES_ADMIN'],"","",$class);}
        if(Settings('EnableGallery',true) && CanAdmin('gallery')) {
            if(IsWebSection('admin/gallery')) { $class = "active"; } else { $class = ""; }
            $content.= SmartLink(Lng('Gallery'),$GLOBALS['urlGALLERY_ADMIN'],"","",$class);}
        if(Settings('EnableContacts',true)) {
            if(IsWebSection('admin/contacts')) { $class = "active"; } else { $class = ""; }
            $content.= SmartLink(Lng('Contacts'),$GLOBALS['urlCONTACTS_ADMIN'],"","",$class);}
        if(IsWebSection('admin/users')) { $class = "active"; } else { $class = ""; }
        $content.= SmartLink(Lng('Users'),$GLOBALS['urlUSERS_ADMIN'],"","",$class);
        if(IsWebSection('admin/settings')) { $class = "active"; } else { $class = ""; }
        if(CanAdmin('settings')) {
            $content.= SmartLink(Lng('Settings'),$GLOBALS['urlSETTINGS_ADMIN'],"","",$class);}
        $layout = $this->ReplacePart("ADMIN_HeaderLeft",$content,$layout);
        $content = "";
        if(IsSet($data)) { UnSet($data); }
        $data['ID'] = "btnLanguage";
        $data['OnClick'] = "OpenFirstMenu(".$MTPS->ClientLayout.",'btnLanguage');";
        $data['OnMouseOver'] = "btnUsernameMouseOver('".$data['ID']."');";
        $content.= SmartLinkEx("<img src=\"<PagePart:urlMTPS:>img/flag/flag-".$MTPS->Language."-h16.png\" height=\"10\" alt=\"\" />",$GLOBALS['urlWEB'],$data);
        $content.= SmartLink(Lng('Leave'),$GLOBALS['urlWEB'],"","");
        if(IsSet($data)) { UnSet($data); }
        $data['ID'] = "btnUsername";
        $data['OnClick'] = "OpenFirstMenu(".$MTPS->ClientLayout.",'btnUsername');";
        $data['OnMouseOver'] = "btnUsernameMouseOver('".$data['ID']."');";
        $data['Style'] = "text-transform: none;";
        if(IsSet($User->Account) && IsSet($User->Account->FirstName) && IsSet($User->Account->LastName) && $User->Account->FirstName != "" && $User->Account->LastName != "") { $username = $User->Account->FirstName.chr(32).$User->Account->LastName; }
        else { $username = $User->Username; }
        $content.= SmartLinkEx($username."<img class=\"arrow\" src=\"<PagePart:urlMTPS:>img/triarrow-down-white-7x8.png\" alt=\"\" />",$GLOBALS['urlUSER'],$data);
        $layout = $this->ReplacePart("ADMIN_HeaderRight",$content,$layout);
        $layout = $this->ReplacePart("ADMIN_ContentLayout",$this->WriteContentLayout($this->ContentLayout),$layout);
        $content = "";
        $content.= "<a href=\"".$GLOBALS['urlWEB']."\">".Lng('MainWebPage')."</a>";
        if(UserCanAccessSection("administration")) { $content.= "<a href=\"".$GLOBALS['urlADMIN']."\">".Lng('Administration')."</a>"; }
        if(ModuleEnabled('pim')) { $content.= "<a href=\"".$GLOBALS['urlPIM']."\">".Lng('Organizer')."</a>"; }
        $layout = $this->ReplacePart("ADMIN_FooterLeft",$content,$layout);
        return $layout;}
    public function PIM_SpecialLayoutFill($layout) {
        global $MTPS, $DB, $User, $Web;
        $content = "";
        if($User->Logged) {
            $content.= "<div class=\"boxi\" style=\"text-align: right; \">".$User->Username."<br /><a href=\"".$GLOBALS['urlUSER']."\">Nastavení účtu</a><br /><a href=\"".AddParam($MTPS->URL,'UserLogout','true')."\">Odhlásit</a></div>";}
        else {
            $content.= "<div class=\"boxi\">".$User->WriteLoginForm($User->Username,$User->RememberLogin,$MTPS->URL)."</div>";}
        $layout = $this->ReplacePart("PIM_SpravceCasuUserInfo",$content,$layout);
        $content = "";
        $layout = $this->ReplacePart("PIM_WebModule",$this->Module,$layout);
        $section = "";
        switch(strtolower($MTPS->PathTwo)) {
            case strtolower(Lng('urlCONTACTS_PIM')): $section = "contacts"; break;
            case strtolower(Lng('urlMAIL_PIM')): $section = "mail"; break;
            case strtolower(Lng('urlCALENDAR_PIM')): $section = "calendar"; break;
            case strtolower(Lng('urlTASKS')): $section = "tasks"; break;
            case strtolower(Lng('urlPROJECTS_PIM')): $section = "projects"; break;
            case strtolower(Lng('urlNOTES_PIM')): $section = "notes"; break;
            case strtolower(Lng('urlDIARY_PIM')): $section = "diary"; break;
            default: $section = "organizer"; break;}
        $layout = $this->ReplacePart("PIM_Section",$section,$layout);
        return $layout;}
    function replaceLngParts($layout) {
        $len = strlen("<Lng:");
        while(($pos = strpos($layout,"<Lng:")) !== false) {
            $pos2 = strpos($layout,":>",$pos);
            if($pos2 !== false) {
                $found = false;
                $result = "";
                $part = substr($layout,$pos+$len,$pos2-$pos-$len);
                $params = explode(";",$part);
                $count = count($params);
                switch($count) {
                    case 1:
                        $found = true;
                        $result = ln($params[0]);
                        break;
                    case 2:
                        $found = true;
                        $result = ln($params[0],$params[1]);
                        break;
                    case 3:
                        $found = true;
                        $result = ln($params[0],$params[1],$params[2]);
                        break;
                    case 4:
                        $found = true;
                        $result = ln($params[0],$params[1],$params[2],$params[3]);
                        break;
                    case 5:
                        $found = true;
                        $result = ln($params[0],$params[1],$params[2],$params[3],$params[4]);
                        break;
                    default:
                        $found = true;
                        WriteLog(AddError("[WEB::replaceLngParts] Unrecognized 'count' = ".$count."!"));
                        $result = "lngError";
                        break;}
                if($found) {
                    $layout = @str_replace("<Lng:$part:>",$result,$layout);}}}
        return $layout;}
    function ReplaceFunctionParts($layout) {
        $len = strlen("<PagePart:");
        for($aa=0; $aa<100; $aa++) {
            $pos = strpos($layout,"<PagePart:");
            if($pos !== false) {
                $pos2 = strpos($layout,":>",$pos);
                if($pos2 !== false) {
                    $found = false;
                    $result = "";
                    $part = substr($layout,$pos+$len,$pos2-$pos-$len);
                    $params = explode(";",$part);
                    switch($params[0]) {
                        case "CSSWidthFromCookie":
                            $found = true;
                            if(IsSet($_COOKIE[$params[1]])) { $result = "width: ".$_COOKIE[$params[1]]."px;"; }
                            break;
                        case "CSSFontSizeFromCookie":
                            $found = true;
                            if(IsSet($_COOKIE[$params[1]])) { $result = "font-size: ".$_COOKIE[$params[1]]."px;"; }
                            break;}
                    if($found) { $layout = $this->ReplacePart($part,$result,$layout); }}}
            else {
                break;}}
        return $layout;}
    function DeleteEmptyParts($layout) {
        $len = strlen("<PagePart:");
        for($aa=0; $aa<50; $aa++) {
            $pos = strpos($layout,"<PagePart:");
            if($pos !== false) {
                $pos2 = strpos($layout,":>",$pos);
                if($pos2 !== false) {
                    $part = substr($layout,$pos+$len,$pos2-$pos-$len);
                    $layout = $this->ReplacePart($part,"",$layout);}}
            else {
                break;}}
        return $layout;}
    public function LoadDefaultLayout($client_layout) {
        global $MTPS;
        $layout = "";
        $layout.= trm("<!doctype html>");
        $layout.= trm("<head lang=\"<PagePart:Language:>\">");
        $layout.= trm("<meta http-equiv=\"content-type\" content=\"text/html; charset=<PagePart:Charset:>\" />");
        if(IsSet($MTPS->Favicon) && $MTPS->Favicon != "") { $layout.= trm("<link rel=\"shortcut icon\" type=\"image/x-icon\" href=\"".$MTPS->Favicon."\" />"); }
        $layout.= trm("<title><PagePart:Title:></title>");
        $layout.= trm("<style>");
        $layout.= trm("body { margin: 0 auto; padding: 0; font-family: Calibri,Arial,sans-serif; color: black; background: white; font-size: 14px; }");
        $layout.= trm("h1 { margin: 0; padding: 0; font-size: 200%; }");
        $layout.= trm("h2 { margin: 0; padding: .7em 0 .5em 0; font-size: 130%; }");
        $layout.= trm("p { margin: 0; padding: 0 0 .5em 0; }");
        $layout.= trm("a { color: black; text-decoration: underline; }");
        $layout.= trm("a:Hover { text-decoration: none; }");
        $layout.= trm("");
        $layout.= trm("");
        $layout.= trm("");
        $layout.= trm(".Report { display: block; border: 1px solid blue; background: aqua; margin: 0 0 7px 0; padding: 5px; font-size: 90%; font-weight: normal; color: black; }");
        $layout.= trm(".Report h7 { display: block; font-weight: bold; font-size: 110%; }");
        $layout.= trm(".ErrorReport { display: block; border: 1px solid maroon; background: red; margin: 0 0 7px 0; padding: 5px; font-size: 90%; font-weight: normal; color: white; }");
        $layout.= trm(".ErrorReport h7 { display: block; font-weight: bold; font-size: 110%; }");
        $layout.= trm(".SuccessReport { display: block; border: 1px solid lime; background: green; margin: 0 0 7px 0; padding: 5px; font-size: 90%; font-weight: normal; color: white; }");
        $layout.= trm(".SuccessReport h7 { display: block; font-weight: bold; font-size: 110%; }");
        $layout.= trm("#Background { padding: 0; background: rgb(245,245,245); }");
        $layout.= trm("#Desk { margin-left: auto; margin-right: auto; padding: 0; width: 950px; background: white; }");
        $layout.= trm("#Web { margin: 0 auto; padding: 1.5em 2.1em 1.5em 2.1em; }");
        $layout.= trm("</style>");
        $layout.= trm("<script>");
        $layout.= trm("function UpdateWebHeight() {");
        $layout.= trm("var windowHeight=0;");
        $layout.= trm("if(typeof(window.innerHeight)=='number') {");
        $layout.= trm("windowHeight = window.innerHeight;");
        $layout.= trm("}");
        $layout.= trm("else {");
        $layout.= trm("if(document.documentElement && document.documentElement.clientHeight) {");
        $layout.= trm("windowHeight = document.documentElement.clientHeight;");
        $layout.= trm("}");
        $layout.= trm("else {");
        $layout.= trm("if(document.body && document.body.clientHeight) {");
        $layout.= trm("windowHeight = document.body.clientHeight;");
        $layout.= trm("}");
        $layout.= trm("}");
        $layout.= trm("}");
        $layout.= trm("if(document.getElementById(\"Desk\").offsetHeight != windowHeight) {");
        $layout.= trm("document.getElementById(\"Desk\").style.height = windowHeight + \"px\";");
        $layout.= trm("}");
        $layout.= trm("return windowHeight;");
        $layout.= trm("}");
        $layout.= trm("</script>");
        $layout.= trm("</head>");
        $this->OnLoad = "UpdateWebHeight();";
        $this->OnResize = "UpdateWebHeight();";
        if($this->OnLoad != "") { $onload = " onload=\"mtpsLoadPageImages();".$this->OnLoad."\""; } else { $onload = " onload=\"mtpsLoadPageImages();\""; }
        if($this->OnResize != "") { $onresize = " onresize=\"".$this->OnResize."\""; } else { $onresize = ""; }
        $layout.= trm("<body lang=\"<PagePart:Language:>\"$onload$onresize>");
        $layout.= trm("<div id=\"Background\">");
        $layout.= trm("<div id=\"Desk\">");
        $layout.= trm("<div id=\"Web\">");
        $layout.= trm("<PagePart:Body:>");
        $layout.= trm("</div>");
        $layout.= trm("</div>");
        $layout.= trm("</div>");
        $layout.= trm("</body>");
        $layout.= trm("</html>");
        return $layout;}
    public function LoadBlankLayout($client_layout) {
        global $MTPS;
        $layout = "";
        $layout.= trm("<!doctype html>");
        $layout.= trm("<head lang=\"<PagePart:Language:>\">");
        $layout.= trm("<meta http-equiv=\"content-type\" content=\"text/html; charset=<PagePart:Charset:>\" />");
        if(IsSet($MTPS->Favicon) && $MTPS->Favicon != "") { $layout.= trm("<link rel=\"shortcut icon\" type=\"image/x-icon\" href=\"".$MTPS->Favicon."\" />"); }
        $layout.= trm("<title><PagePart:Title:></title>");
        $layout.= trm("<style>");
        $layout.= trm("body { margin: 0 auto; padding: 1em; font-family: Calibri,Arial,sans-serif; color: black; background: white; font-size: 14px; }");
        $layout.= trm("h1 { margin: 0; padding: 0; font-size: 200%; }");
        $layout.= trm("h2 { margin: 0; padding: .7em 0 .5em 0; font-size: 130%; }");
        $layout.= trm("p { margin: 0; padding: 0 0 .5em 0; }");
        $layout.= trm("a { color: black; text-decoration: underline; }");
        $layout.= trm("a:hover { text-decoration: none; }");
        $layout.= trm(".Report { display: block; border: 1px solid blue; background: aqua; margin: 0 0 7px 0; padding: 5px; font-size: 90%; font-weight: normal; color: black; }");
        $layout.= trm(".Report h7 { display: block; font-weight: bold; font-size: 110%; }");
        $layout.= trm(".ErrorReport { display: block; border: 1px solid maroon; background: red; margin: 0 0 7px 0; padding: 5px; font-size: 90%; font-weight: normal; color: white; }");
        $layout.= trm(".ErrorReport h7 { display: block; font-weight: bold; font-size: 110%; }");
        $layout.= trm(".SuccessReport { display: block; border: 1px solid lime; background: green; margin: 0 0 7px 0; padding: 5px; font-size: 90%; font-weight: normal; color: white; }");
        $layout.= trm(".SuccessReport h7 { display: block; font-weight: bold; font-size: 110%; }");
        $layout.= trm(".tab_print { width: 100%; margin: 0 0 1em 0; padding: 0; font-size: 100%; border: 0; border-left: 1px solid black; border-top: 1px solid black; color: black; background: white; border-collapse: collapse; border-spacing: 0; }");
        $layout.= trm(".tab_print td, .tab_print th, .tab_print tr { width: auto; font-size: 100%; border: 0; color: black; background: white; }");
        $layout.= trm(".tab_print th { background: rgb(230,230,230); }");
        $layout.= trm(".tab_print td, .tab_print th { text-align: left; vertical-align: top; border: 0; padding: .4em .5em .4em .5em; border-right: 1px solid black; border-bottom: 1px solid black; }");
        $layout.= trm(".tab_print .td_num, .tab_print .th_num { width: 2.5em; text-align: left; }");
        $layout.= trm(".tab_print .td_num { text-align: right; }");
        $layout.= trm("</style>");
        $layout.= trm("</head>");
        $layout.= trm("<body lang=\"<PagePart:Language:>\">");
        $layout.= trm("<div style=\"margin: 0; padding: 0;\"><PagePart:Body:></div>");
        $layout.= trm("</body>");
        $layout.= trm("</html>");
        return $layout;}
    function WriteContentLayout($content_layout) {
        $layout = "";
        switch($content_layout) {
            case "LeftMenu":
                $layout = $this->LoadContentLayout_LeftMenu();
                break;
            case "LeftTree":
                $layout = $this->LoadContentLayout_LeftTree();
                break;}
        if($layout == "") { $layout = "<PagePart:Body:>"; }
        return $layout;}
    function LoadContentLayout_LeftMenu() {
        global $MTPS;
        $left = "";
        $left.= "<div class=\"menu\"><PagePart:LeftMenu:>";
        $left.= "</div>";
        $layout = "";
        $layout.= "<div class=\"left\">$left</div>";
        $layout.= "<div id=\"MainContent\" class=\"right\"><div class=\"content\"><PagePart:Body:></div>";
        $layout.= "</div>";
        $layout.= "<div class=\"clear\"></div>";
        return $layout;}
    function LoadContentLayout_LeftTree() {
        global $MTPS;
        $left = "";
        $left.= "<div class=\"menu\" id=\"LeftTree\">";
        $left.= "<PagePart:LeftMenu:>";
        $left.= "</div>";
        $layout = "";
        $layout.= "<div class=\"left_tree\">$left</div>";
        $layout.= "<div id=\"MainContent\" class=\"right_tree\"><div class=\"content\"><PagePart:Body:></div>";
        $layout.= "</div>";
        $layout.= "<div class=\"clear\"></div>";
        return $layout;}
    function CreatePage($parent_id,$type,$title,$created_by_user_id,$language,$url) {
        global $DB;
        if(($pages = $DB->Select("Pages","`ParentID`=".DBText($parent_id),$count,"`SortPos` DESC, `Created` ASC","1")) !== false && $count > 0) {
            $sort_pos = $pages[0]->SortPos + 1;}
        else {
            $sort_pos = 1;}
        if(IsSet($data)) { UnSet($data); }
        $data['ParentID'] = $parent_id;
        $data['Type'] = $type;
        $data['Title'] = $title;
        $data['SortPos'] = $sort_pos;
        $data['CreatedByUserID'] = $created_by_user_id;
        $page_id = $DB->Insert("Pages",$data);
        if($page_id > 0) {
            if(IsSet($data)) { UnSet($data); }
            $data['PageID'] = $page_id;
            $data['Language'] = $language;
            $data['URL'] = $url;
            $DB->Insert("PagesURLs",$data);}
        return $page_id;}
    function GetTreeOfPages(&$pages_count,$autocreation=false) {
        global $DB, $MTPS, $User;
        $pages_count = 0;
        if(($pages = $DB->SelectTree("Pages","1",0,0,$pages_count,"`SortPos` ASC, `Created` ASC")) !== false && $pages_count > 0) {
            return $pages;}
        else {
            if(!$autocreation) {
                $title['cs'] = Lng('Homepage');
                $title['en'] = $GLOBALS['TEXTS']['Homepage']['en'];
                $json_title = JsonEncode($title);
                $index_id = $this->CreatePage(0,0,$json_title,GetUserAccountID(),$MTPS->Language,'');
                return $this->GetTreeOfPages($pages_count,true);}}
        return false;}
    function LoadPageByType($type) {
        global $DB;
        if(($rows = $DB->Select("Pages","`Type` = '".DBText($type)."'",$count,"","1")) !== false && $count > 0) {
            return $rows[0];}
        return false;
        
    }
    function AddSubPage($values,&$arr) {
        global $DB, $MTPS, $User;
        $report = "";
        if(IsSet($values['ItemID']) && is_numeric($values['ItemID'])) {
            $superior_page_id = $values['ItemID'];
            if(IsSet($values['Title']) && strlen($values['Title']) > 0 && strlen($values['Title']) <= 128) {
                $title[$MTPS->DefaultLanguage] = $values['Title'];
                $name = PageNameToDirName($values['Title']);
                $where = "`ParentID`=".DBText($superior_page_id)." AND `Name`='".DBText($name)."'";
                if(($rows = $DB->Select("Pages",$where,$count)) !== false && $count == 0) {
                    $url = $this->GetPagePathByID($superior_page_id,$MTPS->DefaultLanguage);
                    $url.= $name.'/';
                    $json_title = JsonEncode($title);
                    $new_page_id = $this->CreatePage($superior_page_id,0,$json_title,GetUserAccountID(),$MTPS->Language,$url);
                    if($new_page_id > 0) {
                        $arr['ReloadToURL'] = $GLOBALS['urlWEB'].$url;
                        return true;}
                    else { $report = "[WEB::AddSubPage] Error while CreatePage(); call!"; }}
                else {
                    $report = Lng('PageAlreadyExistsInThisNode',$name);}}
            else {
                $report = Lng('TitleHasWrongLength',1,128);}}
        return false;}
    public function DeleteHtmlComments($layout) {
        while(DeleteBetween($layout,"<!--","-->",$text) != false) { $layout = $text; }
        return $layout;}
    public function TrimLayout($layout) {
        $layout = $this->DeleteHtmlComments($layout);
        $code = "";
        foreach(preg_split("/((\r?\n)|(\r\n?))/",$layout) as $line){
            $code.= trim($line);}
        return $code;}
    function Pages_RenewSubpagesSortPos($page_id) {
        global $DB;
        if(($subpages = $DB->Select("Pages","`ParentID`=".DBText($page_id),$count,"`SortPos` ASC, `Created` ASC")) !== false && $count > 0) {
            for($aa=0; $aa<$count; $aa++) {
                $set = "`SortPos` = '".DBText(($aa+1))."', ";
                $DB->Update("Pages",$set,"`ID` = '".DBText($subpages[$aa]->ID)."'");}}}
    function Pages_MoveSubpage($values,&$arr,$second_pass=false) {
        global $DB, $MTPS, $User;
        $sort_pos = array();
        if(IsSet($values['Move']) && IsSet($values['ItemID']) && is_numeric($values['ItemID']) && IsSet($values['PageID']) && is_numeric($values['PageID'])) {
            if(!CanAdmin("pages-move-subpage",$values['PageID'],$response)) { return false; }
            $move = $values['Move'];
            $parent_id = $values['PageID'];
            $subpage_id = $values['ItemID'];
            if(($subpages = $DB->Select("Pages","`ParentID`=".DBText($parent_id),$count,"`SortPos` ASC, `Created` ASC")) !== false && $count > 0) {
                $moved_att_pos = -1;
                for($aa=0; $aa<$count; $aa++) {
                    if($subpages[$aa]->ID == $subpage_id) {
                        $moved_att_pos = $aa;}
                    $n = 'sp'.$subpages[$aa]->SortPos;
                    if(IsSet($sort_pos[$n]) && !$second_pass) {
                        $this->Pages_RenewSubpagesSortPos($parent_id);
                        return $this->Pages_MoveSubpage($values,$arr,true);}
                    else {
                        $sort_pos[$n] = 1;}}
                if($moved_att_pos != -1) {
                    $replacement_pos = $moved_att_pos;
                    if($move == 'up' && $moved_att_pos > 0) {
                        $replacement_pos = $moved_att_pos-1;}
                    if($move == 'down' && $moved_att_pos < $count-1) {
                        $replacement_pos = $moved_att_pos+1;}
                    $set = "`SortPos` = '".DBText($subpages[$replacement_pos]->SortPos)."', ";
                    $DB->Update("Pages",$set,"`ID` = '".DBText($subpages[$moved_att_pos]->ID)."'");
                    $set = "`SortPos` = '".DBText(($subpages[$moved_att_pos]->SortPos))."', ";
                    $DB->Update("Pages",$set,"`ID` = '".DBText($subpages[$replacement_pos]->ID)."'");
                    $arr['ContentToRefresh'] = $this->WriteListOfNextPages($parent_id,false);
                    return true;}}}
        $arr['Response'] = "[Web::Pages_MoveSubpageDown] Unknown error!";
        return false;}
    function DeletePage($page_id) {
        global $DB;
        $this->Pages_DeleteAllAttachments($page_id);
        $this->Pages_DeleteAllImages($page_id);
        $DB->Delete("PagesContents","`PageID`=".DBText($page_id));
        $DB->Delete("PagesURLs","`PageID`=".DBText($page_id));
        if($DB->Delete("Pages","`ID` = '".DBText($page_id)."'")) { return true; }
        return true;}
    function PageHasChildren($page_id) {
        global $DB;
        if(($pages = $DB->Select("Pages","`ParentID`=".DBText($page_id),$count,"","")) !== false && $count > 0) {
            return true;}
        return false;}
    function ReplaceSubLayout($sub_layout_name,$content,$layout) {
        $content = rtrim($content);
        $layout = @str_replace("<SubLayout:$sub_layout_name:>",$content,$layout);
        return $layout;
    }
    
    function FillSubLayouts($layout) {

        global $MTPS;
        $len = strlen("<SubLayout:");
        for($aa=0; $aa<50; $aa++) {
            $pos = strpos($layout,"<SubLayout:");
            if($pos !== false) {
                $pos2 = strpos($layout,":>",$pos);
                if($pos2 !== false) {
                    $sub_layout_name = substr($layout,$pos+$len,$pos2-$pos-$len);
                    $filename = $sub_layout_name;

                    if($sub_layout_name == "BY_PAGE") {
                        if($MTPS->IsIndexPage || $MTPS->PathOne == "") {
                            $filename = $MTPS->SubLayout['Index'];
                        } else {
                            $slfound = false;
                            //if(Settings('EnableNews',true) && $MTPS->PathOne == Lng('urlNEWS') && IsSet($MTPS->SubLayout['News'])) {
                            //    $slfound = true;
                            //    $filename = $MTPS->SubLayout['News'];
                            //}
//                            error_log("PathOne ".$MTPS->PathOne);

                            if(!$slfound) {
                                $filename = $MTPS->SubLayout['Default'];
                            }

                            if(stripos($MTPS->PathOne,'-vuz')) {
                                $filename = $MTPS->SubLayout['Vuz'];
                            }
                            if($MTPS->PathOne === 'kontakty') {
                                $filename = $MTPS->SubLayout['Kontakty'];
                            }

                        }
                    }
                    $file = $GLOBALS['fileTEMPLATES'].$this->Layout."/".$filename.".layout";
//                    error_log("file ".$file);
                    if(@file_exists($file)) { $content = @file_get_contents($file); } else { $content = ""; }
                    $layout = $this->ReplaceSubLayout($sub_layout_name,$content,$layout);}

                break;
            }
            else {
                break;
            }
        }
        return $layout;
    }
    function ReplacePageMenu($page_menu_id,$content,$layout) {
        $content = rtrim($content);
        $layout = @str_replace("<PageMenu:$page_menu_id:>",$content,$layout);
        return $layout;}
    function FillPageMenus($layout) {
        global $MTPS;
        $len = strlen("<PageMenu:");
        for($aa=0; $aa<50; $aa++) {
            $pos = strpos($layout,"<PageMenu:");
            if($pos !== false) {
                $pos2 = strpos($layout,":>",$pos);
                if($pos2 !== false) {
                    $page_menu_id = substr($layout,$pos+$len,$pos2-$pos-$len);
                    $content = $this->WritePageMenu($page_menu_id,false,false,0,array(),0,false,0,true);
                    $layout = $this->ReplacePageMenu($page_menu_id,$content,$layout);}}
            else {
                break;}}
        return $layout;}
    function ReplaceURL($url_name,$content,$layout) {
        $content = rtrim($content);
        $layout = @str_replace("<URL:$url_name:>",$content,$layout);
        return $layout;}
    function FillURLs($layout) {
        global $MTPS;
        $len = strlen("<URL:");
        for($aa=0; $aa<500; $aa++) {
            $pos = strpos($layout,"<URL:");
            if($pos !== false) {
                $pos2 = strpos($layout,":>",$pos);
                if($pos2 !== false) {
                    $url_name = substr($layout,$pos+$len,$pos2-$pos-$len);
                    if(IsSet($GLOBALS[$url_name])) {
                        $content = $GLOBALS[$url_name];}
                    else {
                        if(is_numeric($url_name)) {
                            $content = $GLOBALS['urlWEB'].$this->GetPagePathByID($url_name,$MTPS->Language);}
                        else {
                            switch($url_name) {
                                case "urlTHIS_CS": $content = CreateLink($GLOBALS['urlWEB'],"cs","","","",true); break;
                                case "urlTHIS_EN": $content = CreateLink($GLOBALS['urlWEB'],"en","","","",true); break;
                                case "urlTHIS_DE": $content = CreateLink($GLOBALS['urlWEB'],"de","","","",true); break;
                                case "urlTHIS_FR": $content = CreateLink($GLOBALS['urlWEB'],"fr","","","",true); break;
                                case "urlTHIS_SR": $content = CreateLink($GLOBALS['urlWEB'],"sr","","","",true); break;
                                case "urlTHIS_RU": $content = CreateLink($GLOBALS['urlWEB'],"ru","","","",true); break;
                                default: $content = ""; break;}}}
                    $layout = $this->ReplaceURL($url_name,$content,$layout);}}
            else {
                break;}}
        return $layout;
    }
    function FillPageIfs($layout) {
//        error_log("FillPageIfs");
        global $DB, $MTPS, $User, $Localhost;
        $len = strlen("<PageIf:");
//        error_log("FillPageIfs len ".$len);

        for($aa=0; $aa<50; $aa++) {
            $pos = strpos($layout,"<PageIf:");
            if($pos !== false) {
                $pos2 = strpos($layout,":>",$pos);
                if($pos2 !== false) {
                    $pageif = substr($layout,$pos+$len,$pos2-$pos-$len);
                    $pos_start = $pos2 + 2;
                    $pos_end = strpos($layout,"</PageIf>",$pos);
                    if($pos_end !== false) {
                        $content = "";
                        $contrue = substr($layout,$pos_start,$pos_end-$pos_start);
                        $all_line = "<PageIf:".$pageif.":>".$contrue."</PageIf>";
                        switch($pageif) {
                            case "Localhost": if($Localhost) { $content = $contrue; } break;
                            case "NotLocalhost": if(!$Localhost) { $content = $contrue; } break;
                            case "IsIndexPage": if($MTPS->IsIndexPage) { $content = $contrue; } break;
                            case "IsNotIndexPage": if(!$MTPS->IsIndexPage) { $content = $contrue; } break;
                            case "HTTPS": if($MTPS->HTTPS) { $content = $contrue; } break;
                            case "NoHTTPS": if(!$MTPS->HTTPS) { $content = $contrue; } break;
                            case "TabletLayout": if($MTPS->ClientLayout == 2) { $content = $contrue; } break;
                            case "MobileLayout": if($MTPS->ClientLayout == 3) { $content = $contrue; } break;
                            case "UserLogged": if($User->Logged) { $content = $contrue; } break;
                            case "UserNotLogged": if(!$User->Logged) { $content = $contrue; } break;
                            case "def_admin": if(defined("admin")) { $content = $contrue; } break;
                            case "def_mtps-dialogs-editor-supertext-windows": if(defined("mtps-dialogs-editor-supertext-windows")) { $content = $contrue; } break;
                            case "!def_mtps-dialogs-editor-supertext-windows": if(!defined("mtps-dialogs-editor-supertext-windows")) { $content = $contrue; } break;
                            case "def_mtps-dialogs-editor-upclick-supertext-windows": if(defined("mtps-dialogs-editor-upclick-supertext-windows")) { $content = $contrue; } break;
                            case "!def_mtps-dialogs-editor-upclick-supertext-windows": if(!defined("mtps-dialogs-editor-upclick-supertext-windows")) { $content = $contrue; } break;
                            case "TSM_HlaseniPoruch": if($MTPS->HTTPS && $MTPS->PathOne == "hlaseni-poruch") { $content = $contrue; } break;
                            case "GalleryAlbumById":
                                $xarr = explode(";",$contrue);
                                $xshow_title = true;
                                if(IsSet($xarr[1])) { $xshow_title = strtolower($xarr[1])=="no-title"?false:true; }
                                $xshow_back = true;
                                if(IsSet($xarr[2])) { $xshow_back = strtolower($xarr[2])=="no-back"?false:true; }
                                $xshow_odoprag = false;
                                if(IsSet($xarr[3])) { $xshow_odoprag = strtolower($xarr[3])=="style-odoprag"?true:false; }
                                $xparams = array();
                                foreach($xarr as $key => $val) {
                                    $parval = explode(":",$val);
                                    if(IsSet($parval[0]) && IsSet($parval[1])) {
                                        $n = trim($parval[0]);
                                        $xparams[$n] = trim($parval[1]);}}
                                if($xshow_odoprag) {
                                    $content = WEB_Gallery_WriteAlbum_StyleOdoprag($xarr[0],$xshow_title,$xshow_back);}
                                else {
                                    $content = WEB_Gallery_WriteAlbum($xarr[0],$xshow_title,$xshow_back,$xparams);}
                                break;
                            case "NewestAttachmentByString":
                                $fstr = RemoveDiacritic($contrue);
                                $fstr = mb_strtolower($fstr,$MTPS->Charset);
                                $fstr = trim($fstr);
                                $content = "nenalezeno";
                                if(Settings('EnablePagesAttachments',true) && ($attachments = $DB->Select("PagesAttachments","`PageID`=".DBText($MTPS->Page->ID)." AND `Published`=1",$attachments_count,"`Created` DESC")) !== false) {
                                    for($ii=0; $ii<$attachments_count; $ii++) {
                                        $ftitle = RemoveDiacritic($attachments[$ii]->Title);
                                        $ftitle = mb_strtolower($ftitle,$MTPS->Charset);
                                        $ftitle = trim($ftitle);
                                        if(strpos($ftitle,$fstr) !== false) {
                                            $content = "<a class=\"pageif-attachment\" href=\"".AddSlashToEnd($GLOBALS['urlWEB']."files/".LngPath()."pages/".$this->GetPagePathByID($MTPS->Page->ID,$MTPS->Language)).$attachments[$ii]->Filename.".".$attachments[$ii]->Extension."\" target=\"_blank\" title=\"Stáhnout soubor ".$attachments[$ii]->Title.".".strtolower($attachments[$ii]->Extension)."\"><img src=\"".GetFileIconByExtension($attachments[$ii]->Extension)."\" alt=\"Soubor ".strtoupper($attachments[$ii]->Extension)."\" />".$attachments[$ii]->Title.".".strtolower($attachments[$ii]->Extension)."</a><span title=\"Velikost souboru\" class=\"pageif-attachment-filesize\">[".CountFileSizeInOptimalUnits($attachments[$ii]->Size)."]</span>";
                                            break;
                                        }
                                    }
                                }
                                break;
                            default:
                                break;}
                        $layout = @str_replace($all_line,$content,$layout);}}}
            else {
                break;
            }
        }
        return $layout;
    }
    function WriteTodayIsFullDate() {
        global $MTPS;
        $str = Lng('TodayIs').chr(32);
        $str.= mb_strtolower(GetDayNameFromStr(Date("D")),$MTPS->Charset).chr(32).Date("j").". ".mb_strtolower(GetMonthName2(Date("n")),$MTPS->Charset).chr(32).Date("Y").".";
        return $str;}
    function WriteTodaysName() {
        return "Svátek má ".NameDay(Date("d.m.")).".";}
    function GetPIMPageStats() {
        global $User, $MTPS;
        $content = "";
        $users_unique_count = $User->GetCountOfTodayLoggedUsers();
        $users_count = $User->GetRealCountOfUsers();
        $content.= "<span>".$users_count."/".$users_unique_count."</span>";
        return $content;}
    function Pages_EditSettings(&$page_id,$_values,&$response) {
        global $DB, $MTPS, $User;
        $response = "";
        $change_page_parent = false;
        $set = "`Type` = '".DBText($_values['PageType'])."', ";
        $set.= "`ShowTitle` = '".DBText($_values['ShowPageTitle'])."', ";
        if($_values['PageType'] == 8 && IsSet($_values['InstitutionCategory'])) {
            $set.= "`RedirectTo` = '".DBText($_values['InstitutionCategory'])."', ";}
        else {
            $set.= "`RedirectTo` = '".DBText($_values['RedirectTo'])."', ";}
        $set.= "`ShowSubpages` = '".DBText($_values['ShowSubpages'])."', ";
        $set.= "`ShowAttachments` = '".DBText($_values['ShowAttachments'])."', ";
        if(IsSet($_values['ParentID']) && is_numeric($_values['ParentID']) && $_values['ParentID'] > 0) {
            if(($page = $this->LoadPageByID($page_id)) !== false && $page->ParentID != $_values['ParentID']) {
                if(CanAdmin("rename-page",$page_id,$response)) {
                    $set.= "`ParentID`=".DBText($_values['ParentID']).", ";
                    $change_page_parent = true;}}}
        if($DB->Update("Pages",$set,"`ID` = '".DBText($page_id)."'")) {
            if($change_page_parent) { return $this->Pages_RenamePageForParentChange($page_id,$response); }
            return true;}
        $response = "[WEB::Pages_EditSetting] Unknown error!";
        return false;}
    public function Pages_RenamePageForParentChange($page_id,&$response="") {
        global $MTPS;
        if(IsSet($page_id) && is_numeric($page_id) && $page_id > 0) {
            if(!CanAdmin("rename-page",$page_id,$response)) { return false; }
            $lngcount = 0;
            if(($page = $this->LoadPageByID($page_id))) {
                foreach($MTPS->SupportedLanguages as $key => $lng) {
                    if(($title = LngStr2($page->Title,$lng)) != "") {
                        if(!$this->Pages_RenamePage_OneLanguage($page_id,$lng,$title,$response,true)) {
                            return false;}}
                    $lngcount++;}}
            $arr['ReloadToURL'] = AddSlashToEnd($GLOBALS['urlWEB'].$this->GetPagePathByID($page_id,$MTPS->Language));
            return true;}
        else {
            $response = "[WEB:Pages_RenamePageForParentChange] PageID value is not defined!";}
        return false;}
    function SetPageTypes() {

        
        global $MTPS;
        $MTPS->PageTypes = array();
        $MTPS->PageTypesCount = 0;
        if(Settings('EnablePages',true)) {

            $MTPS->PageTypes[$MTPS->PageTypesCount] = array();
            $MTPS->PageTypes[$MTPS->PageTypesCount]['Type'] = 0;
            $MTPS->PageTypes[$MTPS->PageTypesCount]['Title'] = "Běžná www stránka s textem a grafikou";
            $MTPS->PageTypesCount++;
        }
        if(Settings('EnableGallery',true)) {
            $MTPS->PageTypes[$MTPS->PageTypesCount] = array();
            $MTPS->PageTypes[$MTPS->PageTypesCount]['Type'] = 1;
            $MTPS->PageTypes[$MTPS->PageTypesCount]['Title'] = "Fotogalerie";
            $MTPS->PageTypesCount++;}
        if(Settings('EnableNews',true)) {
            $MTPS->PageTypes[$MTPS->PageTypesCount] = array();
            $MTPS->PageTypes[$MTPS->PageTypesCount]['Type'] = 2;
            $MTPS->PageTypes[$MTPS->PageTypesCount]['Title'] = "Aktuality";
            $MTPS->PageTypesCount++;}
        if(Settings('EnableEUD',true)) {
            $MTPS->PageTypes[$MTPS->PageTypesCount] = array();
            $MTPS->PageTypes[$MTPS->PageTypesCount]['Type'] = 3;
            $MTPS->PageTypes[$MTPS->PageTypesCount]['Title'] = "Úřední deska EUD";
            $MTPS->PageTypesCount++;}
        if(Settings('EnablePages',true)) {
            $MTPS->PageTypes[$MTPS->PageTypesCount] = array();
            $MTPS->PageTypes[$MTPS->PageTypesCount]['Type'] = 4;
            $MTPS->PageTypes[$MTPS->PageTypesCount]['Title'] = "Mapa webu";
            $MTPS->PageTypesCount++;}
        if(Settings('CreateContactListFromUsers',true)) {
            $MTPS->PageTypes[$MTPS->PageTypesCount] = array();
            $MTPS->PageTypes[$MTPS->PageTypesCount]['Type'] = 5;
            $MTPS->PageTypes[$MTPS->PageTypesCount]['Title'] = "Telefonní seznam sestavený ze seznamu uživatelů";
            $MTPS->PageTypesCount++;}
        if(Settings('EnableDocumentsToDownloadByDepartments',true)) {
            $MTPS->PageTypes[$MTPS->PageTypesCount] = array();
            $MTPS->PageTypes[$MTPS->PageTypesCount]['Type'] = 6;
            $MTPS->PageTypes[$MTPS->PageTypesCount]['Title'] = "Dokumenty ke stažení podle odborů";
            $MTPS->PageTypesCount++;}
        if(Settings('EnableCalendar',true)) {
            $MTPS->PageTypes[$MTPS->PageTypesCount] = array();
            $MTPS->PageTypes[$MTPS->PageTypesCount]['Type'] = 7;
            $MTPS->PageTypes[$MTPS->PageTypesCount]['Title'] = "Kalendář událostí";
            $MTPS->PageTypesCount++;}
        if(Settings('EnableInstitutions',true)) {
            $MTPS->PageTypes[$MTPS->PageTypesCount] = array();
            $MTPS->PageTypes[$MTPS->PageTypesCount]['Type'] = 8;
            $MTPS->PageTypes[$MTPS->PageTypesCount]['Title'] = "Instituce";
            $MTPS->PageTypesCount++;}
        if(Settings('EnableLocalTV',true)) {
            $MTPS->PageTypes[$MTPS->PageTypesCount] = array();
            $MTPS->PageTypes[$MTPS->PageTypesCount]['Type'] = 9;
            $MTPS->PageTypes[$MTPS->PageTypesCount]['Title'] = "Místní TV";
            $MTPS->PageTypesCount++;}
        if(Settings('EnableSportEventsDonations',true)) {
            $MTPS->PageTypes[$MTPS->PageTypesCount] = array();
            $MTPS->PageTypes[$MTPS->PageTypesCount]['Type'] = 10;
            $MTPS->PageTypes[$MTPS->PageTypesCount]['Title'] = "Sportovní akce podporované městem";
            $MTPS->PageTypesCount++;}
        if(Settings('EnableQtronik',true)) {
            $MTPS->PageTypes[$MTPS->PageTypesCount] = array();
            $MTPS->PageTypes[$MTPS->PageTypesCount]['Type'] = 11;
            $MTPS->PageTypes[$MTPS->PageTypesCount]['Title'] = "Qtronik - rezervační systém";
            $MTPS->PageTypesCount++;}
        if(Settings('EnableQtronik',true)) {
            $MTPS->PageTypes[$MTPS->PageTypesCount] = array();
            $MTPS->PageTypes[$MTPS->PageTypesCount]['Type'] = 12;
            $MTPS->PageTypes[$MTPS->PageTypesCount]['Title'] = "Qtronik - zrušení rezervace";
            $MTPS->PageTypesCount++;}
        if(defined("odoprag.cz")) {
            //error_log("SetPageTypes EnablePages ".$MTPS->PageTypesCount);
            $MTPS->PageTypes[$MTPS->PageTypesCount] = array();
            $MTPS->PageTypes[$MTPS->PageTypesCount]['Type'] = 14;
            $MTPS->PageTypes[$MTPS->PageTypesCount]['Title'] = "Ceník PůjčSiMinibus.cz";
            $MTPS->PageTypesCount++;
            $MTPS->PageTypes[$MTPS->PageTypesCount] = array();
            $MTPS->PageTypes[$MTPS->PageTypesCount]['Type'] = 24;
            $MTPS->PageTypes[$MTPS->PageTypesCount]['Title'] = "Vozový park";
            $MTPS->PageTypesCount++;
            $MTPS->PageTypes[$MTPS->PageTypesCount] = array();
            $MTPS->PageTypes[$MTPS->PageTypesCount]['Type'] = 108;
            $MTPS->PageTypes[$MTPS->PageTypesCount]['Title'] = "Vůz";
            $MTPS->PageTypesCount++;
        }
        if(Settings('EnableNews',true) && Settings('EnableEventsFromNews',true)) {
            $MTPS->PageTypes[$MTPS->PageTypesCount] = array();
            $MTPS->PageTypes[$MTPS->PageTypesCount]['Type'] = 18;
            $MTPS->PageTypes[$MTPS->PageTypesCount]['Title'] = "Události z Aktualit";
            $MTPS->PageTypesCount++;}
        if(Settings('EnableContactForm',true)) {
            $MTPS->PageTypes[$MTPS->PageTypesCount] = array();
            $MTPS->PageTypes[$MTPS->PageTypesCount]['Type'] = 19;
            $MTPS->PageTypes[$MTPS->PageTypesCount]['Title'] = "Kontaktní formulář a kontaktní údaje";
            $MTPS->PageTypesCount++;}
        if(Settings('EnablePages',true)) {
            $MTPS->PageTypes[$MTPS->PageTypesCount] = array();
            $MTPS->PageTypes[$MTPS->PageTypesCount]['Type'] = 100;
            $MTPS->PageTypes[$MTPS->PageTypesCount]['Title'] = "Přesměrování na jinou stránku tohoto webu";
            $MTPS->PageTypesCount++;
        }
    }
    
    function WriteCustomForm($form_name,$enable_autofocus=true) {
        $str = "";
        $Form = new FORM($form_name);
        $str = $Form->Write($enable_autofocus);
        return $str;}
    function Pages_WriteInPageAdministrationButtons($state,$page,$sutx_id=-1) {
        $str = "";
        if($page) {
            if($state == "admin") {
                if(CanAdmin("pages-edit-text",$page->ID)) {
                    $str.= "<a onclick=\"Pages_EnableInPageEdit(".$page->ID."); return false;\" href=\"\"><img src=\"".$GLOBALS['urlIMG']."edit-content-32x32.png\" alt=\"".Lng('EditPagesText')."\" />".Lng('EditPagesText')."</a>";}
                if(CanAdmin("pages-change-settings",$page->ID)) {
                    $str.= "<a onclick=\"Pages_PageSettings(".$page->ID."); return false;\" href=\"\">".Lng('PageSettings')."</a>";}
                if(CanAdmin("rename-page",$page->ID)) {
                    $str.= "<a onclick=\"Pages_RenamePage(".$page->ID."); return false;\" href=\"\" title=\"".Lng('RenamePage')."\">".Lng('Rename')."</a>";}
                if(CanAdmin("pages-delete-page",$page->ID)) {
                    $qtext = str_replace("\"","&quot;",Lng('DoYouReallyWant').chr(32).Lng('ToRemovePage',LngStr($page->Title))."?<br />Tato akce nenávratně vymaže všechny přílohy a vložené obrázky!");
                    $str.= "<a onclick=\"Dialog_YesCancel(".$page->ID.",'".Lng('DeletePage')."','".$qtext."','Pages_DeletePage'); return false;\" href=\"\" title=\"".Lng('DeletePage')."\">".Lng('Remove')."</a>";}
                if(defined("odoprag.cz") && ($page->Type == 14 || $page->Type == 24)) {
                    $str.= "<a onclick=\"Odoprag_EditCars(); return false;\" href=\"\" title=\"Editovat seznam aut\">Auta</a>";
                }
                    
            }
            if($state == "edit") {
                $str.= "<a onclick=\"Pages_SaveContent(".$sutx_id."); return false;\" href=\"\"><img src=\"".$GLOBALS['urlIMG']."wysiwyg/save.png\" alt=\"".Lng('Publish')."\" />".Lng('Publish')."</a>";
                $str.= "<a onclick=\"Pages_ExitInPageEdit(".$page->ID."); return false;\" href=\"\">".Lng('ExitTextEditation')."</a>";}}
        return $str;}
    function WriteMapOfWeb($parent_id=0) {
        global $MTPS, $DB;
        $str = "";
        if(($pages = $DB->SelectTree("Pages","",$parent_id,0,$pages_count,"`SortPos` ASC, `Created` ASC")) !== false && $pages_count > 0) {
            $str.= "<div class=\"map-of-the-web\">";
            $str.= "<ul>";
            for($aa=0; $aa<$pages_count; $aa++) {
                $str.= "<li style=\"margin-left: ".(.5+($pages[$aa]->TreePos*1.5))."em;\"><a href=\"".$GLOBALS['urlWEB'].$this->GetPagePathByID($pages[$aa]->ID,$MTPS->Language)."\" title=\"".LngStr($pages[$aa]->Title)."\">".LngStr($pages[$aa]->Title)."</a></li>";}
            $str.= "</ul>";
            $str.= "</div>";}
        return $str;}
    function Downloads_DocumentsByDepartments_OneDept($department_id,$title,$docs,$docs_count,$write_div=true) {
        global $MTPS;
        $str = "";
        $count = 0;
        $list = array();
        for($aa=0; $aa<$docs_count; $aa++) {
            if($docs[$aa]->DepartmentID == $department_id) {
                $list[$count] = $aa;
                $count++;}
            else if(IsSet($list[0])) { break; }}
        if($count > 0 || CanAdmin("downloads-add-document-by-department",$department_id)) {
            if($write_div) { $str.= "<div class=\"mtps-downloads-documents\" id=\"ListOfDocumentsToDownload".$department_id."\">"; }
            $str.= "<h2>".$title."</h2>";
            $str.= "<table>";
            for($aa=0; $aa<$count; $aa++) {
                $admin_tr = "";
                if(CanAdmin("downloads-move-document-by-department",$department_id)) {
                    $admin_tr.= " onmouseenter=\"SetVisibility('ListOfDocumentsToDownload_IconRename".$docs[$list[$aa]]->ID."','visible'); SetVisibility('ListOfDocumentsToDownload_IconDelete".$docs[$list[$aa]]->ID."','visible');\"";
                    $admin_tr.= " onmouseleave=\"SetVisibility('ListOfDocumentsToDownload_IconRename".$docs[$list[$aa]]->ID."','hidden'); SetVisibility('ListOfDocumentsToDownload_IconDelete".$docs[$list[$aa]]->ID."','hidden');\"";}
                $str.= "<tr id=\"ListOfDocumentsToDownload_Line".$docs[$list[$aa]]->ID."\"$admin_tr>";
                if(CanAdmin("downloads-move-document-by-department",$department_id) && $count > 1) {
                    if(Settings('UseWhiteAdminArrows')) { $arrtype = "-white"; } else { $arrtype = ""; }
                    if($aa > 0) { $str.= "<td class=\"clickicon\" onclick=\"Downloads_MoveDocumentByDepartment('up',".$department_id.",".$docs[$list[$aa]]->ID."); return false;\" title=\"Posunout dokument nahoru\"><img src=\"".$GLOBALS['urlIMG']."arrow-up$arrtype-32x32.png\" alt=\"Posunout dokument nahoru\" /></td>"; } else { $str.= "<td class=\"noclickicon\">&nbsp;</td>"; }
                    if($aa < $count-1) { $str.= "<td class=\"clickicon\" onclick=\"Downloads_MoveDocumentByDepartment('down',".$department_id.",".$docs[$list[$aa]]->ID."); return false;\" title=\"Posunout dokument dolů\"><img src=\"".$GLOBALS['urlIMG']."arrow-down$arrtype-32x32.png\" alt=\"Posunout dokument dolů\" /></td>"; } else { $str.= "<td class=\"noclickicon\">&nbsp;</td>"; }}
                $department_path = LngEx($docs[$list[$aa]]->Language,"urlGENERAL");
                if($docs[$list[$aa]]->DepartmentID > 0 && ($department_title = $this->GetDepartmentTitleByID($docs[$list[$aa]]->DepartmentID,$MTPS->DefaultLanguage)) != "") {
                    $department_path = PageNameToDirName($department_title);}
                $path = AddSlashToEnd("files/".$docs[$list[$aa]]->Language."/".LngEx($docs[$list[$aa]]->Language,"urlDOCUMENTS")."/".LngEx($docs[$list[$aa]]->Language,"urlDEPARTMENT")."/".$department_path);
                $file = $GLOBALS['urlWEB'].$path.$docs[$list[$aa]]->Filename.".".$docs[$list[$aa]]->Extension;
                $str.= "<td><a onclick=\"DownloadFile('downloads-document-by-department',".$docs[$list[$aa]]->ID."); return false;\" href=\"".$file."\" target=\"_blank\" title=\"Stáhnout soubor ".$docs[$list[$aa]]->Title.".".strtolower($docs[$list[$aa]]->Extension)."\"><img src=\"".GetFileIconByExtension($docs[$list[$aa]]->Extension)."\" alt=\"Soubor ".strtoupper($docs[$list[$aa]]->Extension)."\" />".$docs[$list[$aa]]->Title.".".strtolower($docs[$list[$aa]]->Extension)."</a><span title=\"Velikost souboru\" class=\"file-size\">[".CountFileSizeInOptimalUnits($docs[$list[$aa]]->Size)."]</span></td>";
                if(CanAdmin("downloads-rename-document-by-department",$department_id)) {
                    $str.= "<td class=\"clickicon\" onclick=\"Dialog_EditTitle(".$docs[$list[$aa]]->ID.",'Přejmenovat dokument','".$docs[$list[$aa]]->Title."','Downloads_RenameDocumentByDepartment',".$department_id."); return false;\" title=\"Přejmenovat dokument\"><img style=\"visibility:hidden;\" src=\"".$GLOBALS['urlIMG']."rename-pencil-32x32.png\" alt=\"Přejmenovat dokument\" id=\"ListOfDocumentsToDownload_IconRename".$docs[$list[$aa]]->ID."\" /></td>";}
                if(CanAdmin("downloads-delete-document-by-department",$department_id)) {
                    $text = str_replace("\"","&quot;","Opravdu si přejete vymazat dokument \"".$docs[$list[$aa]]->Title.".".strtolower($docs[$list[$aa]]->Extension)."\"?");
                    $str.= "<td class=\"clickicon\" onclick=\"Dialog_YesCancel(".$docs[$list[$aa]]->ID.",'Vymazat dokument','$text','Downloads_DeleteDocumentByDepartment',".$department_id."); return false;\" title=\"Vymazat dokument\"><img style=\"visibility:hidden;\" src=\"".$GLOBALS['urlIMG']."delete-red-32x32.png\" alt=\"Vymazat dokument\" id=\"ListOfDocumentsToDownload_IconDelete".$docs[$list[$aa]]->ID."\" /></td>";}
                $str.= "</tr>";}
            $str.= "</table>";
            if(CanAdmin("downloads-add-document-by-department",$department_id)) {
                $str.= "<p class=\"mtps-page-buttons\">";
                $str.= "<a href=\"\" onclick=\"Downloads_AddDocumentByDepartment(".$department_id."); return false;\"><img src=\"".$GLOBALS['urlIMG']."attachment.png\" alt=\"".Lng('Add')."\" />".Lng('Add')."</a>";
                $str.= "</p>";}
            if($write_div) { $str.= "</div>"; }}
        return $str;}
    function Downloads_WriteDocumentsByDepartments($department_id=-1) {
        global $MTPS, $DB, $User;
        $str = "";
        if(Settings('DocumentsToDownloadByDepartments_NewestAtBottom',true)) { $att_sort = "ASC"; } else { $att_sort = "DESC"; }
        if($department_id > -1) { $department = "`DepartmentID` = '".DBText($department_id)."' AND "; $write_div = false; } else { $department = ""; $write_div = true; }
        if(Settings('EnableDocumentsToDownloadByDepartments',true) && ($docs = $DB->Select("DocumentsToDownloadByDepartments",$department."`Published` = '1'",$count,"`DepartmentID` ASC, `SortPos` $att_sort, `Created` ASC")) !== false) {
            if(($departments = $DB->Select("Departments","`ShowInContacts` = 1",$departments_count,"`SortPos` ASC, `Title` ASC")) !== false && $departments_count >= 0) {
                if($department_id <= 0) {
                    $str.= $this->Downloads_DocumentsByDepartments_OneDept(0,"Obecné dokumenty",$docs,$count,$write_div);}
                if($department_id != 0) {
                    for($dd=0; $dd<$departments_count; $dd++) {
                        if($department_id == -1 || ($department_id > 0 && $department_id == $departments[$dd]->ID)) {
                            $str.= $this->Downloads_DocumentsByDepartments_OneDept($departments[$dd]->ID,LngStr($departments[$dd]->Title),$docs,$count,$write_div);}}}}}
        return $str;}
    function Downloads_AddDocumentByDepartment(&$document_id,$department_id,$language,$filename,$ext,$filesize,&$response) {
        global $DB, $MTPS, $User;
        if(!CanAdmin("downloads-add-document-by-department",$department_id,$response)) { return false; }
        $response = "";
        if(IsSet($data)) { UnSet($data); }
        $data['Type'] = 0;
        $data['DepartmentID'] = $department_id;
        $data['Language'] = $language;
        $data['Filename'] = $filename;
        $data['Extension'] = $ext;
        $data['Size'] = $filesize;
        $data['Published'] = 0;
        $data['CreatedByUserID'] = GetUserAccountID();
        if(($document_id = $DB->Insert("DocumentsToDownloadByDepartments",$data,$response)) !== false) {
            return true;}
        if($response == "") { $response = "[WEB::Downloads_AddDocumentByDepartment] Unknown error!"; }
        return false;}
    function Downloads_PublishDocumentByDepartment($values,&$arr) {
        global $DB, $MTPS, $User;
        if(IsSet($values['ItemID']) && is_numeric($values['ItemID']) && IsSet($values['DepartmentID']) && is_numeric($values['DepartmentID'])) {
            if(!CanAdmin("downloads-add-document-by-department",$values['DepartmentID'],$response)) { return false; }
            if(($documents = $DB->Select("DocumentsToDownloadByDepartments","`DepartmentID` = '".DBText($values['DepartmentID'])."' AND `Published` = '1'",$count,"`SortPos` DESC, `Created` ASC","1")) !== false && $count > 0) {
                $sort_pos = $documents[0]->SortPos + 1;}
            else {
                $sort_pos = 1;}
            $set = "`Published` = '1', ";
            $set.= "`Title` = '".DBText($values['Title'])."', ";
            $set.= "`SortPos` = '".DBText($sort_pos)."', ";
            if($DB->Update("DocumentsToDownloadByDepartments",$set,"`ID` = '".DBText($values['ItemID'])."' AND `DepartmentID` = '".DBText($values['DepartmentID'])."'",$arr['Response'])) {
                $arr['ContentToRefresh'] = $this->Downloads_WriteDocumentsByDepartments($values['DepartmentID']);
                return true;}}
        else {
            $arr['Response'] = "[Web::Downloads_PublishDocumentByDepartment] Unknown error!";}
        return false;}
    function Downloads_LoadDocumentByDepartmentByID($document_id) {
        global $DB;
        if(($documents = $DB->Select("DocumentsToDownloadByDepartments","`ID` = '".DBText($document_id)."' AND `Published` = '1'",$count,"","1")) !== false && $count > 0) {
            return $documents[0];}
        return false;}
    function Downloads_RenewDocumentByDepartmentsSortPos($department_id) {
        global $DB;
        if(($documents = $DB->Select("DocumentsToDownloadByDepartments","`DepartmentID` = '".DBText($department_id)."' AND `Published` = '1'",$count,"`SortPos` ASC, `Created` ASC")) !== false && $count > 0) {
            for($aa=0; $aa<$count; $aa++) {
                $set = "`SortPos` = '".DBText(($aa+1))."', ";
                $DB->Update("DocumentsToDownloadByDepartments",$set,"`ID` = '".DBText($documents[$aa]->ID)."'");}}}
    function Downloads_MoveDocumentByDepartment($values,&$arr,$second_pass=false) {
        global $DB, $MTPS, $User;
        $sort_pos = array();
        if(IsSet($values['Move']) && IsSet($values['ItemID']) && is_numeric($values['ItemID']) && IsSet($values['DepartmentID']) && is_numeric($values['DepartmentID'])) {
            if(!CanAdmin("downloads-move-document-by-department",$values['DepartmentID'],$response)) { return false; }
            $move = $values['Move'];
            $department_id = $values['DepartmentID'];
            $document_id = $values['ItemID'];
            if(($documents = $DB->Select("DocumentsToDownloadByDepartments","`DepartmentID` = '".DBText($department_id)."' AND `Published` = '1'",$count,"`SortPos` ASC, `Created` ASC")) !== false && $count > 0) {
                $moved_att_pos = -1;
                for($aa=0; $aa<$count; $aa++) {
                    if($documents[$aa]->ID == $document_id) {
                        $moved_att_pos = $aa;}
                    $n = 'sp'.$documents[$aa]->SortPos;
                    if(IsSet($sort_pos[$n]) && !$second_pass) {
                        $this->Downloads_RenewDocumentByDepartmentsSortPos($department_id);
                        return $this->Downloads_MoveDocumentByDepartment($values,$arr,true);}
                    else {
                        $sort_pos[$n] = 1;}}
                if($moved_att_pos != -1) {
                    $replacement_pos = $moved_att_pos;
                    if(Settings('DownloadDocumentByDepartments_NewestAtBottom',true)) {
                        if($move == 'up' && $moved_att_pos > 0) {
                            $replacement_pos = $moved_att_pos-1;}
                        if($move == 'down' && $moved_att_pos < $count-1) {
                            $replacement_pos = $moved_att_pos+1;}}
                    else {
                        if($move == 'down' && $moved_att_pos > 0) {
                            $replacement_pos = $moved_att_pos-1;}
                        if($move == 'up' && $moved_att_pos < $count-1) {
                            $replacement_pos = $moved_att_pos+1;}}
                    $set = "`SortPos` = '".DBText($documents[$replacement_pos]->SortPos)."', ";
                    $DB->Update("DocumentsToDownloadByDepartments",$set,"`ID` = '".DBText($documents[$moved_att_pos]->ID)."'");
                    $set = "`SortPos` = '".DBText(($documents[$moved_att_pos]->SortPos))."', ";
                    $DB->Update("DocumentsToDownloadByDepartments",$set,"`ID` = '".DBText($documents[$replacement_pos]->ID)."'");
                    $arr['ContentToRefresh'] = $this->Downloads_WriteDocumentsByDepartments($department_id);
                    return true;}}}
        $arr['Response'] = "[Web::Downloads_MoveDocumentByDepartmentDown] Unknown error!";
        return false;}
    function Downloads_DeleteDocumentByDepartment($values,&$arr) {
        global $DB, $MTPS, $User, $Web;
        if(IsSet($values['DocumentID']) && is_numeric($values['DocumentID']) && IsSet($values['DepartmentID']) && is_numeric($values['DepartmentID'])) {
            if(!CanAdmin("downloads-delete-document-by-department",$values['DepartmentID'],$response)) { return false; }
            if(($documents = $DB->Select("DocumentsToDownloadByDepartments","`ID` = '".DBText($values['DocumentID'])."' AND `DepartmentID` = '".DBText($values['DepartmentID'])."'",$count)) !== false && $count > 0) {
                $department_path = LngEx($documents[0]->Language,"urlGENERAL");
                if($documents[0]->DepartmentID > 0 && ($department_title = $this->GetDepartmentTitleByID($documents[0]->DepartmentID,$MTPS->DefaultLanguage)) != "") {
                    $department_path = PageNameToDirName($department_title);}
                $path = AddSlashToEnd("files/".$documents[0]->Language."/".LngEx($documents[0]->Language,"urlDOCUMENTS")."/".LngEx($documents[0]->Language,"urlDEPARTMENT")."/".$department_path);
                $file = $GLOBALS['fileWEB'].$path.$documents[0]->Filename.".".$documents[0]->Extension;
                $arr['File'] = $file;
                if(($arr['FileExists'] = file_exists($file))) {
                    $arr['UnlinkResult'] = DeleteFile($file);}
                $DB->Delete("DocumentsToDownloadByDepartments","`ID` = '".DBText($values['DocumentID'])."'");
                $arr['ContentToRefresh'] = $this->Downloads_WriteDocumentsByDepartments($values['DepartmentID']);
                return true;}
            else {
                $arr['Response'] = "[Web::Downloads_DeleteDocumentByDepartment] DocumentID or DepartmentID not found!";}}
        else {
            $arr['Response'] = "[Web::Downloads_DeleteDocumentByDepartment] Unknown error!";}
        return false;}
    function Downloads_DeleteDocumentByDepartmentFile($values,&$arr) {
        global $DB, $MTPS, $User, $Web;
        if(IsSet($values['DocumentID']) && is_numeric($values['DocumentID'])) {
            if(($documents = $DB->Select("DocumentsToDownloadByDepartments","`ID` = '".DBText($values['DocumentID'])."'",$count)) !== false && $count > 0) {
                if(!CanAdmin("downloads-delete-document-by-department",$documents[0]->DepartmentID,$response)) { return false; }
                $department_path = LngEx($documents[0]->Language,"urlGENERAL");
                if($documents[0]->DepartmentID > 0 && ($department_title = $this->GetDepartmentTitleByID($documents[0]->DepartmentID,$MTPS->DefaultLanguage)) != "") {
                    $department_path = PageNameToDirName($department_title);}
                $path = AddSlashToEnd("files/".$documents[0]->Language."/".LngEx($documents[0]->Language,"urlDOCUMENTS")."/".LngEx($documents[0]->Language,"urlDEPARTMENT")."/".$department_path);
                $file = $GLOBALS['fileWEB'].$path.$documents[0]->Filename.".".$documents[0]->Extension;
                $arr['File'] = $file;
                if(($arr['FileExists'] = file_exists($file))) {
                    $arr['UnlinkResult'] = DeleteFile($file);}
                $DB->Delete("DocumentsToDownloadByDepartments","`ID` = '".DBText($values['DocumentID'])."'");
                return true;}
            else {
                $arr['Response'] = "[Web::Downloads_DeleteDocumentByDepartmentFile] DocumentID not found!";}}
        else {
            $arr['Response'] = "[Web::Downloads_DeleteDocumentByDepartmentFile] Unknown error!";}
        return false;}
    function Downloads_RenameDocumentByDepartment($values,&$arr) {
        global $DB;
        if(IsSet($values['Title']) && IsSet($values['DocumentID']) && is_numeric($values['DocumentID']) && IsSet($values['DepartmentID']) && is_numeric($values['DepartmentID'])) {
            if(!CanAdmin("downloads-rename-document-by-department",$values['DepartmentID'],$response)) { return false; }
            $set = "`Title` = '".DBText($values['Title'])."', ";
            if($DB->Update("DocumentsToDownloadByDepartments",$set,"`ID` = '".DBText($values['DocumentID'])."' AND `DepartmentID` = '".DBText($values['DepartmentID'])."'",$arr['Response'])) {
                $arr['ContentToRefresh'] = $this->Downloads_WriteDocumentsByDepartments($values['DepartmentID']);
                return true;}}
        else {
            $arr['Response'] = "[Web::Downloads_RenameDocumentByDepartment] Unknown error!";}
        return false;}
//KD 20200605
    function SendPoptavkuFromSimpleWebForm($values,&$arr) {
        //$MTPS;
        global $MTPS;
        $arr['Response'] = "";
        if(IsSet($values['SenderEmail'])) {
            if(IsSet($values['Question']) && strlen($values['Question']) >= 10) {
                //if(IsSet($values['RecipientEmail'])) {
                    if(TestEmail($values['SenderEmail'],$arr['Response'])) {
                        //if(TestEmail($values['RecipientEmail'],$arr['Response'])) {
                            if($values['SenderName'] != "") { $reply_to_name = $values['SenderName'];
                            } else {
                                $reply_to_name = $values['SenderEmail'];
                            }
                            $text = "";
                            if(IsSet($values['SenderName'])) { $text.= "<p><b>Jméno:</b> ".$values['SenderName']."</p>"; }
                            if(IsSet($values['SenderPhone'])) { $text.= "<p><b>Telefon:</b> ".$values['SenderPhone']."</p>"; }
                            if(IsSet($values['SenderEmail'])) { $text.= "<p><b>E-mail:</b> ".$values['SenderEmail']."</p>"; }
                            if(IsSet($values['Question'])) { $text.= "<p><b>Dotaz:</b> ".urldecode($values['Question'])."</p>"; }
SendEmail(true,1,$MTPS->EmailInfo,$MTPS->EmailInfoName,"Dotaz z webu ".$_SERVER['HTTP_HOST'],$text,false,"",0,$values['SenderEmail'],$reply_to_name);
//webmasterovi
SendEmail(true,1,$MTPS->EmailWebmaster,$MTPS->EmailWebmasterName,"Dotaz z webu ".$_SERVER['HTTP_HOST'],$text,false,"",0,$values['SenderEmail'],$reply_to_name);
//poptávajícímu
$text .="<p>Vaší zprávě se budeme neodkladně věnovat. </p>";
$text .="<p>Děkujeme Vám a přejeme pěkný den</p>";

SendEmail(true,1,$values['SenderEmail'],$reply_to_name,"Potvrzení dotazu na webu ".$_SERVER['HTTP_HOST'],$text,false,"",0,$MTPS->EmailInfo,$MTPS->EmailInfoName);


                            return true;
                        //} else {
                        //    $arr['Response'].= "\nChyba při vyplnění položky \"E-mail odesílatele\"!";
                        //}
                    }
                    else {
                        $arr['Response'].= "\nChyba při vyplnění položky \"Váš e-mail\"!";}}
                //else {
                //    $arr['Response'] = "Není vyplněna položka E-mail příjemce.";}}
            else {
                $arr['Response'] = "Není vyplněna položka Dotaz.";}}
        else {
            $arr['Response'] = "Není položka Váš e-mail.";}
        return false;}
    
    
    
    function SendQuestionFromSimpleWebForm($values,&$arr) {
        $MTPS;
        $arr['Response'] = "";
        if(IsSet($values['SenderEmail'])) {
            if(IsSet($values['Question']) && strlen($values['Question']) >= 10) {
                if(IsSet($values['RecipientEmail'])) {
                    if(TestEmail($values['SenderEmail'],$arr['Response'])) {
                        if(TestEmail($values['RecipientEmail'],$arr['Response'])) {
                            if($values['SenderName'] != "") { $reply_to_name = $values['SenderName']; } else { $reply_to_name = $values['SenderEmail']; }
                            $text = "";
                            if(IsSet($values['SenderName'])) { $text.= "<p><b>Jméno:</b> ".$values['SenderName']."</p>"; }
                            if(IsSet($values['SenderPhone'])) { $text.= "<p><b>Telefon:</b> ".$values['SenderPhone']."</p>"; }
                            if(IsSet($values['SenderEmail'])) { $text.= "<p><b>E-mail:</b> ".$values['SenderEmail']."</p>"; }
                            if(IsSet($values['Question'])) { $text.= "<p><b>Dotaz:</b> ".urldecode($values['Question'])."</p>"; }
                            SendEmail(true,1,$values['RecipientEmail'],$reply_to_name,"Dotaz z webu ".$_SERVER['HTTP_HOST'],$text,false,"",0,$values['SenderEmail'],$reply_to_name);
                            return true;
                        } else {
                            $arr['Response'].= "\nChyba při vyplnění položky \"E-mail odesílatele\"!";}}
                    else {
                        $arr['Response'].= "\nChyba při vyplnění položky \"Váš e-mail\"!";}}
                else {
                    $arr['Response'] = "Není vyplněna položka E-mail příjemce.";}}
            else {
                $arr['Response'] = "Není vyplněna položka Dotaz.";}}
        else {
            $arr['Response'] = "Není položka Váš e-mail.";}
        return false;}
    public function SearchIn($vals,&$arr) {
        if(IsSet($vals['In']) && strlen($vals['In']) > 0 && IsSet($vals['For']) && strlen($vals['For']) >= 2 && IsSet($vals['Begin']) && is_numeric($vals['Begin']) && $vals['Begin'] >= 0 && IsSet($vals['LastID']) && is_numeric($vals['LastID']) && $vals['LastID'] >= 0) {
            $arr['In'] = $vals['In'];
            $arr['For'] = $vals['For'];
            $arr['LastID'] = $vals['LastID'];
            if($vals['Begin'] == 0) { $vals['Begin'] = 2147483647; }
            $arr['Begin'] = $vals['Begin'];
            $arr['Items'] = array(); $items_count = 0;
            if($vals['In'] == "News" && Settings('EnableNews')) {
                if(($item = $this->FindStringInDBTable("News","Title","PlainText",$vals['For'],$arr)) !== false) {
                    $arr['Items'][$items_count] = new stdClass();
                    $arr['Items'][$items_count]->Title = $item->Title;
                    $arr['Items'][$items_count]->Text = $item->PlainText;
                    $arr['Items'][$items_count]->URL = $GLOBALS['urlWEB'].Lng('urlNEWS')."/".$item->ID;
                    $items_count++;}}
            return true;}
        return false;}
    private function FindStringInDBTable($table_name,$title,$text,$search_for,&$arr) {
        global $DB;
        $words = explode(chr(32),$search_for);
        $title_and = ""; $title_or = ""; $text_and = ""; $text_or = "";
        foreach($words as $key => $val) {
            if(strlen($val) >= 2) {
                if($title_and != "") { $title_and.= " AND "; }
                $title_and.= "`".DBText($title)."` LIKE '%".DBText($val)."%'";
                if($title_or != "") { $title_or.= " OR "; }
                $title_or.= "`".DBText($title)."` LIKE '%".DBText($val)."%'";
                if($text_and != "") { $text_and.= " AND "; }
                $text_and.= "`".DBText($text)."` LIKE '%".DBText($val)."%'";
                if($text_or != "") { $text_or.= " OR "; }
                $text_or.= "`".DBText($text)."` LIKE '%".DBText($val)."%'";}}
        $item = false;
        if($item === false && ($rows = $DB->Select($table_name,"`Created` < '".DBText($arr['Begin'])."' AND `ID` != '".DBText($arr['LastID'])."' AND ((".$title_or.") OR (".$text_or."))",$count,"`Created` DESC","1")) !== false && $count > 0) { $item = $rows[0]; }
        if($item) {
            $arr['Begin'] = $item->Created;
            $arr['LastID'] = $item->ID;
            return $item;}
        return false;}
    function SearchInNews($search_for,$parent_id=0) {
        if(!Settings('EnableNews')) { return ""; }
        $str = "";
        $str.= "<script type=\"text/javascript\">";
        $str.= "g_SearchCounter = 0;";
        $str.= "function MTPSSearchTimeout() {";
        $str.= "if(typeof MTPSSearch == 'function'){ MTPSSearch('News','".$search_for."'); }";
        $str.= "else { setTimeout(function(){MTPSSearchTimeout();},750); }";
        $str.= "}";
        $str.= "setTimeout(function(){MTPSSearchTimeout();},100);";
        $str.= "</script>";
        $str.= "<div id=\"SearchInNews_Main\" class=\"ajax-web-search\">";
        $str.= "<h2>Prohledávám aktuality...</h2>";
        $str.= "<p><img src=\"".$GLOBALS['urlIMG']."loader/ajax_loader_gray_32.gif\" /></p>";
        $str.= "</div>";
        return $str;}
    function SearchInPages($search_for,$parent_id=0) {
        if(!Settings('EnablePages')) { return ""; }
        global $MTPS, $DB;
        $str = "";
        $search_for = strtolower($search_for);
        $found_count = 0;
        $list = array();
        if(($rows = $DB->Select("Pages","`Type` = '0'",$count,"`Changed` DESC")) !== false && $count > 0) {
            for($aa=0; $aa<$count; $aa++) {
                $text = strtolower(LngStr($rows[$aa]->Title));
                if(strpos($text,$search_for) !== false) {
                    $list[$found_count] = new stdClass();
                    $list[$found_count]->Title = LngStr($rows[$aa]->Title);
                    $list[$found_count]->Link = $this->GetPagePathByID($rows[$aa]->ID,$MTPS->Language);
                    $found_count++;}
                else {
                    if(($content = $this->LoadPageContent($rows[$aa]->ID,$MTPS->Language,true)) !== false) {
                        $text = strtolower($content->Content);
                        $text = str_replace("</div>","</div> ",$text);
                        $text = str_replace("</p>","</p> ",$text);
                        $text = str_replace("<br />",chr(32),$text);
                        $text = strip_tags($text);
                        $text = html_entity_decode($text);
                        if(strpos($text,$search_for) !== false) {
                            $list[$found_count] = new stdClass();
                            $list[$found_count]->Title = LngStr($rows[$aa]->Title);
                            $list[$found_count]->Link = $this->GetPagePathByID($rows[$aa]->ID,$MTPS->Language);
                            $found_count++;}}}}}
        if($found_count == 0) { $str.= "<h2>Hledaný výraz nebyl nalezen.</h2>"; }
        else {
            $str.= "<h2>Nalezeno $found_count výsledků:</h2>";
            for($aa=0; $aa<$found_count; $aa++) {
                $str.= "<p>&nbsp;-&nbsp;<a href=\"".$GLOBALS['urlWEB'].$list[$aa]->Link."\">".$list[$aa]->Title."</a></p>";}}
        return $str;}
    public function Pages_GetInstitutionCategories(&$arr) {
        global $DB;
        $arr['Count'] = 0;
        $arr['Items'] = array();
        if(Settings('EnableInstitutions') && ($arr['Items'] = $DB->Select("InstitutionsCategories","",$arr['Count'],"`Title` ASC")) !== false && $arr['Count'] > 0) {
            return true;}
        return true;}
    public function Institutions_Load2($values,&$arr) {
        global $DB, $MTPS;
        $arr['Count'] = 0;
        if(Settings('EnableInstitutions') && IsSet($values['InstitutionID']) && ($rows = $DB->Select("Institutions","`ID` = '".DBText($values['InstitutionID'])."'",$arr['Count'])) !== false && $arr['Count'] > 0) {
            return $rows[0];}
        return false;}
    public function Institutions_Load($values,&$arr) {
        global $DB, $MTPS;
        $arr['Count'] = 0;
        if(Settings('EnableInstitutions') && IsSet($values['InstitutionID']) && ($rows = $DB->Select("Institutions","`ID` = '".DBText($values['InstitutionID'])."'",$arr['Count'])) !== false && $arr['Count'] > 0) {
            $arr['Institution'] = $rows[0];
            return true;}
        return false;}
    public function Institutions_LoadCategory($values,&$arr) {
        global $DB, $MTPS;
        $arr['Count'] = 0;
        if(Settings('EnableInstitutions') && IsSet($values['CategoryID']) && ($rows = $DB->Select("InstitutionsCategories","`ID` = '".DBText($values['CategoryID'])."'",$arr['Count'],"`Title` ASC")) !== false && $arr['Count'] > 0) {
            $titles = json_decode($rows[0]->Title,true);
            foreach($MTPS->SupportedLanguages as $key => $lng) {
                $arr['Title_'.$lng] = $titles[$lng];}
            return true;}
        return false;}
    public function Institutions_LoadCategoryByID($category_id) {
        global $DB;
        if(Settings('EnableInstitutions') && ($rows = $DB->Select("InstitutionsCategories","`ID` = '".DBText($category_id)."'",$count)) !== false && $count > 0) {
            return $rows[0];}
        return false;}
    public function Institutions_LoadCategoryByTitle($title) {
        global $DB;
        if(Settings('EnableInstitutions') && ($rows = $DB->Select("InstitutionsCategories","`Title` LIKE '%".DBText($title)."%'",$count)) !== false && $count > 0) {
            return $rows[0];}
        return false;}
    function Institutions_WriteMainTitle($title,$category_id=0) {
        global $DB;
        $str = "";
        if(CanAdmin('edit-institutions')) {
            $str.= "<div class=\"page-admin-title\">";
            $str.= "<h1>".$title."</h1>";
            $str.= "<div class=\"page-admin-title-buttons\" style=\"width: 15em;\">";
            $str.= "<p class=\"mtps-page-buttons\">";
            $str.= "<a href=\"\" id=\"Institutions_NewInstitutionBtn\" style=\"visibility: hidden;\" onclick=\"Institutions_Edit(0,".$category_id."); return false;\"><img src=\"".$GLOBALS['urlIMG']."add-green-circle-64x64.png\" alt=\"".Lng('NewInstitution')."\" />".Lng('NewInstitution')."</a>";
            $str.= "</p>";
            $str.= "</div>";
            $str.= "</div>";}
        else {
            $str.= "<h1>".$title."</h1>";}
        return $str;}
    public function WriteInstitutions($category_id,$from_ajax=false) {
        global $DB, $MTPS;
        $str = "";
        if(Settings('EnableInstitutions')) {
            if($category_id == 0 && !$from_ajax) {
                $str.= "<div class=\"institutions-category-switch\">";
                $str.= "<span>Filtrovat:</span>";
                $str.= "<select id=\"InstitutionsCategory\" onchange=\"Institutions_CategoryFilterChange('InstitutionsCategory');\">";
                $str.= "<option value=\"0\" selected=\"selected\">Všechny kategorie</option>";
                if(($categories = $DB->Select("InstitutionsCategories","",$categories_count,"`Title` ASC")) !== false && $categories_count > 0) {
                    for($aa=0; $aa<$categories_count; $aa++) {
                        $str.= "<option value=\"".$categories[$aa]->ID."\">".LngStr($categories[$aa]->Title)."</option>";}}
                $str.= "</select>";
                if(CanAdmin('edit-institutions')) {
                    $str.= "<a href=\"\" onclick=\"Institutions_EditCategory(document.getElementById('InstitutionsCategory').value); return false;\">".Lng('Settings')."</a>";
                    $str.= "<a href=\"\" onclick=\"Institutions_EditCategory(0); return false;\">".Lng('NewCategory')."</a>";}
                $str.= "</div>";}
            if($this->Layout == "") { $layout = $MTPS->DefaultLayout; } else { $layout = $this->Layout; }
            $where = "";
            if($category_id > 0) { $where = "`CategoryID` = '".DBText($category_id)."'"; }
            $str.= "<div id=\"ListOfInstitutions\">";
            $str.= "<h2>".Lng('Institutions').":</h2>";
            if(($rows = $DB->Select("Institutions",$where,$count,"`Title` ASC")) !== false && $count > 0) {
                for($aa=0; $aa<$count; $aa++) {
                    $str.= "<table class=\"institution\">";
                    $str.= "<tr>";
                    $str.= "<th>";
                    $onclick = "";
                    if(CanAdmin('edit-institutions')) { $onclick = " onclick=\"Institutions_EditIcon(".$rows[$aa]->ID."); return false;\""; }
                    if($rows[$aa]->IconFilename != "") {
                        $str.= "<a$onclick href=\"".$GLOBALS['imgWEB']."image/file/gallery/institutions/".$rows[$aa]->ID."/".$rows[$aa]->IconFilename."\" target=\"_blank\"><img id=\"Institutions_IconImage".$rows[$aa]->ID."\" src=\"".$GLOBALS['imgWEB']."image/file/gallery/institutions/".$rows[$aa]->ID."/".$rows[$aa]->IconFilename."?Width=".($MTPS->InstitutionIconWidth*$MTPS->EM)."\" alt=\"".htmlspecialchars(LngStr($rows[$aa]->Title))."\" /></a>";}
                    else {
                        $str.= "<a$onclick href=\"".$GLOBALS['urlTEMPLATES'].$layout."/institution-default-icon.png\" target=\"_blank\"><img id=\"Institutions_IconImage".$rows[$aa]->ID."\" src=\"".$GLOBALS['urlTEMPLATES'].$layout."/institution-default-icon.png\" alt=\"".htmlspecialchars(LngStr($rows[$aa]->Title))."\" /></a>";}
                    $str.= "</th>";
                    $str.= "<td>";
                    $str.= "<table class=\"institution-data\">";
                    if(CanAdmin('edit-institutions')) {
                        $str.= "<tr><td colspan=\"2\"><h2><a href=\"\" onclick=\"Institutions_Edit(".$rows[$aa]->ID.",".$rows[$aa]->CategoryID."); return false;\">".LngStr($rows[$aa]->Title)."</a></h2></td></tr>";}
                    else {
                        $str.= "<tr><td colspan=\"2\"><h2>".LngStr($rows[$aa]->Title)."</h2></td></tr>";}
                    if(IsSet($rows[$aa]->Address) && strlen($rows[$aa]->Address) > 0) { $str.= "<tr><td style=\"font-weight: bold;\" colspan=\"2\">".$rows[$aa]->Address."</td></tr>"; }
                    if(IsSet($rows[$aa]->Note) && strlen(LngStr($rows[$aa]->Note)) > 0) { $str.= "<tr><td style=\"font-style: italic;\" colspan=\"2\">".LngStr($rows[$aa]->Note)."</td></tr>"; }
                    if(IsSet($rows[$aa]->URL) && strlen($rows[$aa]->URL) > 0 && $rows[$aa]->URL != "http://") { $str.= "<tr><td class=\"idtitle\">".Lng('Web').":</td><td><a href=\"".$rows[$aa]->URL."\" target=\"_blank\">".$rows[$aa]->URL."</a></td></tr>"; }
                    if(IsSet($rows[$aa]->Email) && strlen($rows[$aa]->Email) > 0) { $str.= "<tr><td class=\"idtitle\">".Lng('Email').":</td><td><a href=\"mailto:".$rows[$aa]->Email."\">".$rows[$aa]->Email."</a></td></tr>"; }
                    if(IsSet($rows[$aa]->Telephone) && strlen($rows[$aa]->Telephone) > 0) { $str.= "<tr><td class=\"idtitle\">".Lng('Telephone').":</td><td>".WritePhoneNumber($rows[$aa]->Telephone)."</td></tr>"; }
                    if(IsSet($rows[$aa]->MobilePhone) && strlen($rows[$aa]->MobilePhone) > 0) { $str.= "<tr><td class=\"idtitle\">".Lng('MobilePhoneShort').":</td><td>".WritePhoneNumber($rows[$aa]->MobilePhone)."</td></tr>"; }
                    if(IsSet($rows[$aa]->Fax) && strlen($rows[$aa]->Fax) > 0) { $str.= "<tr><td class=\"idtitle\">".Lng('Fax').":</td><td>".WritePhoneNumber($rows[$aa]->Fax)."</td></tr>"; }
                    $str.= "</table>";
                    $str.= "</td>";
                    $str.= "</tr>";
                    $str.= "</table>";}}
            $str.= "</div>";}
        return $str;}
    public function Institutions_Save($values,&$arr) {
        global $DB, $MTPS;
        if(IsSet($values['CategoryID']) && is_numeric($values['CategoryID']) && IsSet($values['InstitutionID']) && is_numeric($values['InstitutionID'])) {
            if($values['InstitutionID'] == 0) {
                $titles = array();
                foreach($MTPS->SupportedLanguages as $key => $lng) {
                    $n = 'Title_'.$lng;
                    if(IsSet($values[$n])) { $titles[$lng] = $values[$n]; } else { $titles[$lng] = ""; }}
                $notes = array();
                foreach($MTPS->SupportedLanguages as $key => $lng) {
                    $n = 'Note_'.$lng;
                    if(IsSet($values[$n])) { $notes[$lng] = $values[$n]; } else { $notes[$lng] = ""; }}
                if(IsSet($data)) { UnSet($data); }
                if(IsSet($values['CategoryID'])) { $data['CategoryID'] = $values['CategoryID']; }
                $data['Title'] = JsonEncode($titles);
                $data['Note'] = JsonEncode($notes);
                if(IsSet($values['Telephone'])) { $data['Telephone'] = $values['Telephone']; }
                if(IsSet($values['MobilePhone'])) { $data['MobilePhone'] = $values['MobilePhone']; }
                if(IsSet($values['Fax'])) { $data['Fax'] = $values['Fax']; }
                if(IsSet($values['Email'])) { $data['Email'] = $values['Email']; }
                if(IsSet($values['URL'])) { $data['URL'] = $values['URL']; }
                if(IsSet($values['Address'])) { $data['Address'] = $values['Address']; }
                if($DB->Insert("Institutions",$data,$arr['Response']) !== false) {
                    return true;}}
            else {
                if(($institution = $this->Institutions_Load2($values,$arr)) !== false) {
                    $titles = json_decode($institution->Title,true);
                    foreach($MTPS->SupportedLanguages as $key => $lng) {
                        $n = 'Title_'.$lng;
                        if(IsSet($values[$n])) { $titles[$lng] = $values[$n]; } else { $titles[$lng] = ""; }}
                    $notes = json_decode($institution->Note,true);
                    foreach($MTPS->SupportedLanguages as $key => $lng) {
                        $n = 'Note_'.$lng;
                        if(IsSet($values[$n])) { $notes[$lng] = $values[$n]; } else { $notes[$lng] = ""; }}
                    $set = "";
                    $set.= "`CategoryID` = '".DBText($values['CategoryID'])."', ";
                    $set.= "`Title` = '".DBText(JsonEncode($titles))."', ";
                    $set.= "`Note` = '".DBText(JsonEncode($notes))."', ";
                    if(IsSet($values['Telephone'])) { $set.= "`Telephone` = '".DBText($values['Telephone'])."', "; }
                    if(IsSet($values['MobilePhone'])) { $set.= "`MobilePhone` = '".DBText($values['MobilePhone'])."', "; }
                    if(IsSet($values['Fax'])) { $set.= "`Fax` = '".DBText($values['Fax'])."', "; }
                    if(IsSet($values['Email'])) { $set.= "`Email` = '".DBText($values['Email'])."', "; }
                    if(IsSet($values['URL'])) { $set.= "`URL` = '".DBText($values['URL'])."', "; }
                    if(IsSet($values['Address'])) { $set.= "`Address` = '".DBText($values['Address'])."', "; }
                    if($DB->Update("Institutions",$set,"`ID` = '".DBText($values['InstitutionID'])."'")) {
                        return true;}}}}
        else {
            $arr['Response'] = "[WEB::Institutions_Save] Hodnota CategoryID a/nebo InstitutionID není definována!";}
        return false;}
    public function Institutions_SaveCategory($values,&$arr) {
        global $DB, $MTPS;
        if(IsSet($values['CategoryID']) && is_numeric($values['CategoryID'])) {
            if($values['CategoryID'] == 0) {
                if($this->Institutions_LoadCategoryByTitle($values['Title_cs']) == false) {
                    $titles = array();
                    foreach($MTPS->SupportedLanguages as $key => $lng) {
                        $n = 'Title_'.$lng;
                        if(IsSet($values[$n])) { $titles[$lng] = $values[$n]; } else { $titles[$lng] = ""; }}
                    if(IsSet($data)) { UnSet($data); }
                    $data['Title'] = JsonEncode($titles);
                    if($DB->Insert("InstitutionsCategories",$data,$arr['Response']) !== false) {
                        return true;}}
                else {
                    $arr['Response'] = "[WEB::Institutions_SaveCategory] Kategorie s tímto názvem již existuje!";}}
            else {
                if(($category = $this->Institutions_LoadCategoryByID($values['CategoryID'])) !== false) {
                    $titles = json_decode($category->Title,true);
                    foreach($MTPS->SupportedLanguages as $key => $lng) {
                        $n = 'Title_'.$lng;
                        if(IsSet($values[$n])) { $titles[$lng] = $values[$n]; } else { $titles[$lng] = ""; }}
                    if($DB->Update("InstitutionsCategories","`Title` = '".DBText(JsonEncode($titles))."', ","`ID` = '".DBText($values['CategoryID'])."'")) {
                        return true;}}}}
        return false;}
    public function Institutions_LoadByID($institution_id) {
        global $DB, $MTPS, $User;
        if(($institutions = $DB->Select("Institutions","`ID` = '".DBText($institution_id)."'",$count)) !== false && $count > 0) {
            return $institutions[0];}
        return false;}
    public function Institutions_AddIcon($values,&$arr) {
        global $DB, $MTPS;
        $arr['Response'] = "";
        if(IsSet($values['InstitutionID']) && is_numeric($values['InstitutionID']) && IsSet($values['Filename']) && IsSet($values['Ext'])) {
            $institution_id = $values['InstitutionID'];
            $institutions = $this->Institutions_LoadByID($institution_id,false);
            if($institutions !== false) {
                $old_filename = $institutions->IconFilename;}
            else {
                $old_filename = "";}
            if(!CanAdmin("edit-institutions",false,$arr['Response'])) { return false; }
            $icon_filename = $values['Filename'].".".$values['Ext'];
            $set = "`IconFilename` = '".DBText($icon_filename)."', ";
            if($DB->Update("Institutions",$set,"`ID` = '".DBText($institution_id)."'")) {
                if($old_filename != "") {
                    $root = $GLOBALS['fileWEB'];
                    $path = AddSlashToEnd("gallery/institutions/".$institution_id);
                    if(file_exists($root.$path.$old_filename)) { DeleteFile($root.$path.$old_filename); }}
                return true;}}
        return false;}
    public function Institutions_DeleteUnusedIcon($values,&$arr) {
        global $DB, $MTPS;
        $arr['Response'] = "";
        if(IsSet($values['InstitutionID']) && is_numeric($values['InstitutionID']) && IsSet($values['Filename']) && IsSet($values['Ext'])) {
            $institution_id = $values['InstitutionID'];
            if(!CanAdmin("edit-institutions",false,$arr['Response'])) { return false; }
            $icon_filename = $values['Filename'].".".$values['Ext'];
            if($icon_filename != "") {
                $root = $GLOBALS['fileWEB'];
                $path = AddSlashToEnd("gallery/institutions/".$institution_id);
                $arr['DeletedFile'] = $root.$path.$icon_filename;
                if(file_exists($root.$path.$icon_filename)) { $arr['Unlink'] = DeleteFile($root.$path.$icon_filename); }}
            return true;}
        return false;}
    public function RSS_Intelis_inCity($source,$name="") {
        $str = "<".chr(63)."xml version=\"1.0\" encoding=\"utf-8\"".chr(63).">\n";
        $str.= "<rss version=\"2.0\">";
        $str.= "<channel>\n";
        switch(strtolower($source)) {
            case "news": $str.= $this->RSS_Intelis_inCity_News(); break;
            case "board": $str.= $this->RSS_Intelis_inCity_Board(); break;
            case "events": $str.= $this->RSS_Intelis_inCity_Events(); break;
            case Lng('urlCALENDARS'): $str.= $this->RSS_Intelis_inCity_Calendars($name); break;}
        $str.= "</channel>\n";
        $str.= "</rss>\n";
        return $str;}
    public function RSS_Intelis_inCity_Calendars($name) {
        global $User, $DB, $MTPS, $PIM, $Web;
        $str = "";
        $str.= "<last_build_time>".Date("c")."</last_build_time>\n";
        $str.= "<events>\n";
        if(($organizer = $PIM->LoadOrganizerByName($name)) !== false && $organizer->Visibility == 1) {
            $PIM->LoadEventTypes();
            if(($records = $DB->Select("PIM_Records","`OrganizerID` = '".DBText($organizer->ID)."' AND `Visibility` = '1' AND `HasBegin` = '1' AND (`DateBegin` >= '".DBText(Date("Y-m-d"))."' OR `DateEnd` >= '".DBText(Date("Y-m-d"))."')",$records_count,"","500")) !== false && $records_count > 0) {
                for($aa=0; $aa<$records_count; $aa++) {
                    $str.= "<event last_modified=\"".Date("Y-m-d",$records[$aa]->Changed)."T".Date("H:i:s",$records[$aa]->Changed)."+01:00\">\n";
                    $str.= "<id>".$records[$aa]->ID."</id>\n";
                    $str.= "<title>\n";
                    $str.= "<![CDATA[".$PIM->GetEventTypeTitle($records[$aa]->EventType,": ").$records[$aa]->Text."]]>\n";
                    $str.= "</title>\n";
                    $str.= "<description>\n";
                    $str.= "<![CDATA[".$records[$aa]->Note."]]>\n";
                    $str.= "</description>\n";
                    $str.= "<address>\n";
                    $str.= "<place>Kralupy nad Vltavou</place>\n";
                    $str.= "<street>Palackého nám. 1</street>\n";
                    $str.= "<city>Kralupy nad Vltavou</city>\n";
                    $str.= "<gps>\n";
                    $str.= "<latitude>50.241262</latitude>\n";
                    $str.= "<longitude>14.310949</longitude>\n";
                    $str.= "</gps>\n";
                    $str.= "<end_gps>\n";
                    $str.= "<latitude>50.241262</latitude>\n";
                    $str.= "<longitude>14.310949</longitude>\n";
                    $str.= "</end_gps>\n";
                    $str.= "<altitude>200</altitude>\n";
                    $str.= "<end_altitude>200</end_altitude>\n";
                    $str.= "</address>\n";
                    $str.= "<dates>\n";
                    $str.= "<date>\n";
                    $str.= "<start_time>".$records[$aa]->DateBegin."T".$records[$aa]->TimeBegin."</start_time>\n";
                    $str.= "<end_time>".$records[$aa]->DateEnd."T".$records[$aa]->TimeEnd."</end_time>\n";
                    $str.= "</date>\n";
                    $str.= "</dates>\n";
                    $str.= "<opening_hours></opening_hours>\n";
                    $str.= "<categories>\n";
                    $str.= "<categorie_title>Obecné</categorie_title>\n";
                    $str.= "</categories>\n";
                    $str.= "<organizer>\n";
                    $str.= "<name>Město Kralupy nad Vltavou</name>\n";
                    $str.= "<person>Lenka Moravcová</person>\n";
                    $str.= "<phone>".WritePhoneNumber("420315739811")."</phone>\n";
                    $str.= "<email>mesto@mestokralupy.cz</email>\n";
                    $str.= "<url>http://www.mestokralupy.cz</url>\n";
                    $str.= "</organizer>\n";
                    $str.= "<admission>Zdarma</admission>\n";
                    $str.= "<booking_url>http://www.mestokralupy.cz</booking_url>\n";
                    $str.= "<related_url>".$GLOBALS['urlWEB'].Lng('urlCALENDARS')."/kralupy/".$records[$aa]->ID."</related_url>\n";
                    if($this->Layout == "") { $layout = $MTPS->DefaultLayout; } else { $layout = $this->Layout; }
                    if($records[$aa]->MainPicture > 0) {
                        $image = $GLOBALS['imgWEB']."gallery/pim/calendars/".$records[$aa]->OrganizerID."/events/".$records[$aa]->ID."/main-picture-".$records[$aa]->MainPicture.".jpg";
                        $icon = $GLOBALS['imgWEB']."image/file/gallery/pim/calendars/".$records[$aa]->OrganizerID."/events/".$records[$aa]->ID."/main-picture-".$records[$aa]->MainPicture.".jpg?Square=128";}
                    else {
                        $image = $GLOBALS['imgWEB']."pagelogo.png";
                        $icon = $GLOBALS['imgWEB']."pagelogo-128x128.png";}
                    $str.= "<image_url>".$image."</image_url>\n";
                    $str.= "<icon_url>".$icon."</icon_url>\n";
                    $str.= "<photos>\n";
                    $str.= "<photo_url></photo_url>\n";
                    $str.= "</photos>\n";
                    $str.= "</event>\n";}}}
        $str.= "</events>\n";
        return $str;}
    public function RSS_Intelis_inCity_News() {
        global $User, $DB, $MTPS;
        $str = "";
        $str.= "<title>Aktuality města Kralupy nad Vltavou</title>\n";
        $str.= "<link>".$GLOBALS['urlWEB']."</link>\n";
        $str.= "<description></description>\n";
        $str.= "<language>".$MTPS->Language."</language>\n";
        $str.= "<lastBuildDate>".Date("c")."</lastBuildDate>\n";
        if(($news = WEB_News_GetPublishedNews($count,"0, 100")) !== false && $count > 0) {
            for($aa=0; $aa<$count; $aa++) {
                $str.= "<item last_modified=\"".$news[$aa]->PublishedDate."T".$news[$aa]->PublishedTime."+01:00\">\n";
                $str.= "<id>".$news[$aa]->ID."</id>\n";
                $str.= "<link>".$GLOBALS['urlWEB'].Lng('urlNEWS')."/".$news[$aa]->ID."</link>\n";
                $str.= "<title>\n";
                $str.= "<![CDATA[".iconv('UTF-8','UTF-8//IGNORE',strip_tags($news[$aa]->Title))."]]>\n";
                $str.= "</title>\n";
                $str.= "<description>\n";
                $_text = $news[$aa]->Text;
                $_text = str_replace (">","> ",$_text);
                $_text = str_replace (chr(32).chr(32),chr(32),$_text);
                $_text = str_replace (" :",":",$_text);
                $_text = trim($_text);
                $_text = strip_tags($_text);
                $_text = RepairUTF8($_text);
                $str.= "<![CDATA[".$_text."]]>\n";
                $str.= "</description>\n";
                $str.= "<pubDate>".$news[$aa]->PublishedDate."T".$news[$aa]->PublishedTime."+01:00</pubDate>\n";
                $user = $User->LoadUserByID($news[$aa]->CreatedByUserID);
                if($user !== false) {
                    $author_name = $user->FirstName.chr(32).$user->LastName;
                    if($user->FirstName == "" && $user->LastName == "") { $author_name = $user->Username; }}
                else {
                    $author_name = "Administrátor";}
                $str.= "<authorName>".$author_name."</authorName>\n";
                $str.= "<categories>\n";
                $category = WEB_News_LoadCategoryByID($news[$aa]->CategoryID);
                $str.= "<categorie_title>".$category->Title."</categorie_title>\n";
                $str.= "</categories>\n";
                $str.= "<related_url>".$GLOBALS['urlWEB'].Lng('urlNEWS')."/".$news[$aa]->ID."</related_url>\n";
                if($news[$aa]->IconFilename != "") {
                    $attdate = explode("-",$news[$aa]->CreatedDate);
                    $image = $GLOBALS['imgWEB']."image/file/gallery/".LngPath($news[$aa]->Language)."news/".$attdate[0]."/".$attdate[1]."/".$attdate[2]."/".$news[$aa]->ID."/".$news[$aa]->IconFilename."?AtLeast=600";
                    $icon = $GLOBALS['imgWEB']."image/file/gallery/".LngPath($news[$aa]->Language)."news/".$attdate[0]."/".$attdate[1]."/".$attdate[2]."/".$news[$aa]->ID."/".$news[$aa]->IconFilename."?Width=128";}
                else {
                    if($this->Layout == "") { $layout = $MTPS->DefaultLayout; } else { $layout = $this->Layout; }
                    $image = $GLOBALS['urlTEMPLATES'].$layout."/news-default-icon-full.png";
                    $icon = $GLOBALS['urlTEMPLATES'].$layout."/news-default-icon-full.png";}
                $str.= "<image_url>".$image."</image_url>\n";
                $str.= "<icon_url>".$icon."</icon_url>\n";
                $str.= "<photos>\n";
                $str.= "<photo_url/>\n";
                $str.= "</photos>\n";
                $str.= "</item>\n";}}
        return $str;}
    public function RSS_Intelis_inCity_Board() {
        global $User, $DB, $MTPS;
        $str = "";
        $str.= "<title>Úřední deska města Kralupy nad Vltavou</title>\n";
        $str.= "<link>".$GLOBALS['urlWEB']."</link>\n";
        $str.= "<description></description>\n";
        $str.= "<language>".$MTPS->Language."</language>\n";
        $str.= "<lastBuildDate>".Date("c")."</lastBuildDate>\n";
        if(($eud = WEB_EUD_GetPublishedEUD(false,false,$count)) !== false && $count > 0) {
            if(($page = $this->LoadPageByType(3)) !== false) { $path = $this->GetPagePathByID($page->ID,$MTPS->Language); }
            for($aa=0; $aa<$count; $aa++) {
                $str.= "<item last_modified=\"".Date("c",$eud[$aa]->Changed)."\">\n";
                $str.= "<id>".$eud[$aa]->ID."</id>\n";
                $str.= "<title>\n";
                $str.= "<![CDATA[".$eud[$aa]->Title."]]>\n";
                $str.= "</title>\n";
                $str.= "<link>".$GLOBALS['urlWEB'].$path.$eud[$aa]->ID."</link>\n";
                $str.= "<description>\n";
                $_text = $eud[$aa]->Text;
                $_text = str_replace (">","> ",$_text);
                $_text = str_replace (chr(32).chr(32),chr(32),$_text);
                $_text = str_replace (" :",":",$_text);
                $_text = trim($_text);
                $_text = strip_tags($_text);
                $_text = RepairUTF8($_text);
                $str.= "<![CDATA[".$_text."]]>\n";
                $str.= "</description>\n";
                $str.= "<pubDate>".$eud[$aa]->DateFrom."T00:00:00+01:00</pubDate>\n";
                $str.= "<pubUntil>".$eud[$aa]->DateTo."T23:59:59+01:00</pubUntil>\n";
                $str.= "<fileNumber>".$eud[$aa]->NegotiatingID."</fileNumber>\n";
                $str.= "<section>".$eud[$aa]->Source."</section>\n";
                $str.= "<categories>\n";
                $str.= "<categorie_title>".$eud[$aa]->Category."</categorie_title>\n";
                $str.= "</categories>\n";
                $str.= "</item>\n";}}
        return $str;}
    public function RSS_Intelis_inCity_Events() {
        global $User, $DB;
        $str = "";
        return $str;}
    function WriteSpravceCasuCalendarBox($type) {
        global $MTPS;
        if($GLOBALS['Localhost']) {
            if($MTPS->MySQL_Host == "127.0.0.1") {
                return "<script type=\"text/javascript\" src=\"https://www.casospravce.mukpy.cz/box/kalendare/kralupy?Type=".$type."&Title=".urlencode("Kalendář událostí ve městě a okolí")."\" charset=\"utf-8\"></script>";}
            else {
                return "<script type=\"text/javascript\" src=\"https://www.casospravce.mukpy.cz/box/kalendare/kralupy?Type=".$type."&Title=".urlencode("Kalendář událostí ve městě a okolí")."\" charset=\"utf-8\"></script>";}}
        else {
            if($MTPS->HTTPS == 1) {
                return "<script type=\"text/javascript\" src=\"https://www.spravcecasu.cz/box/kalendare/kralupy?Type=".$type."&Title=".urlencode("Kalendář událostí ve městě a okolí")."\" charset=\"utf-8\"></script>";}
            else {
                return "<script type=\"text/javascript\" src=\"http://www.spravcecasu.cz/box/kalendare/kralupy?Type=".$type."&Title=".urlencode("Kalendář událostí ve městě a okolí")."\" charset=\"utf-8\"></script>";}}
    }
    
    public function PageParentIsType($searched_type) {
        global $MTPS;
        if($MTPS->PageParents !== false) {
            for($aa=0; $aa<$MTPS->PageParentsCount; $aa++) {
                if($MTPS->PageParents[$MTPS->PageParentsCount-$aa-1]->Type == $searched_type) { return true; }}}
        return false;
    }
    
    function Qtronik_WriteFullPage() {
        $str = "";
        if(Settings('EnableQtronik')) {
            $str.= "<script type=\"text/javascript\">function resizeIframe(obj) { obj.style.height = obj.contentWindow.document.body.scrollHeight + 'px'; if(mtps && mtps.scrollBodyTopTo){ mtps.scrollBodyTopTo(kwi.getTop('QtronikIframe')); }; document.body.scrollTop = 0; }</script>";
            $str.= "<div class=\"iframe-wrapper\"><iframe id=\"QtronikIframe\" frameborder=\"0\" scrolling=\"no\" class=\"qtronik-iframe\" src=\"".$GLOBALS['imgWEB']."qtronik/index.php\" onload=\"javascript:resizeIframe(this);\"></iframe></div>";}
        else {
            AddError("[Qtronik_WriteFullPage] Qtronik is not enabled.");}
        return $str;}
    function Qtronik_WriteCancelPage() {
        $str = "";
        if(Settings('EnableQtronik') && IsSet($_GET['data'])) {
            $str.= "<div class=\"content\"><a href=\"".$GLOBALS['urlWEB']."qtronik/cancel.php?data=".$_GET['data']."&e\" target=\"_blank\">Kliknutím SEM zrušíte Vaši rezervaci</a></div>";}
        else {
            AddError("Funkce není povolena.");}
        return $str;}
    
    public function OdopragCz_MainMenu() {
        global $MTPS;
        $str = "";
        $str.= "<div class=\"mainmenubox\">";
        $str.= "<a class=\"".($MTPS->PathOne==""?"active":"")."\" href=\"<URL:1:>\"><span id=\"_mnu1\">Domů</span></a> ";
        $str.= "<a class=\"".($MTPS->PathOne=="vozovy-park"?"active":"")."\" href=\"<URL:9:>\" title=\"Vozový park\"><span id=\"_mnu22\">Auta</span></a> ";
//        if(CanAdmin()) {
//            $str.= "<a class=\"".($MTPS->PathOne=="fotogalerie"?"active":"")."\" href=\"<URL:13:>\"><span id=\"_mnu23\">Fotogalerie</span></a> ";}
        $str.= "<a class=\"".($MTPS->PathOne=="nosic-kol"?"active":"")."\" href=\"<URL:10:>\"><span id=\"_mnu24\">Nosič kol</span></a> ";
        $str.= "<a class=\"".($MTPS->PathOne=="detske-sedacky-k-pujceni"?"active":"")."\" href=\"<URL:11:>\"><span id=\"_mnu25\">Dětské sedačky</span></a> ";
        $str.= "<a class=\"".($MTPS->PathOne=="dulezite-informace"?"active":"")."\" href=\"<URL:2:>\"><span id=\"_mnu3\">Důležité informace</span></a> ";
        $str.= "<a class=\"".($MTPS->PathOne=="cenik"?"active":"")."\" href=\"<URL:3:>\"><span id=\"_mnu4\">Ceník</span></a> ";
        $str.= "<a class=\"".($MTPS->PathOne=="poptavka"?"active":"")."\" href=\"<URL:4:>\"><span id=\"_mnu5\">Poptávka</span></a> ";
        $str.= "<a class=\"".($MTPS->PathOne=="rady-na-cesty"?"active":"")."\" href=\"<URL:6:>\"><span id=\"_mnu7\">Rady na cesty</span></a> ";
/*        $str.= "<a class=\"".($MTPS->PathOne=="reference"?"active":"")."\" href=\"<URL:12:>\"><span id=\"_mnu26\">Reference</span></a> ";*/
        $str.= "<a class=\"".($MTPS->PathOne=="kontakty"?"active":"")."\" href=\"<URL:7:>\"><span id=\"_mnu8\">Kontakty</span></a> ";
        $str.= "</div>";
        return $str;
        }
    
    public function OdopragCz_Calculace() {
        global $MTPS, $DB;
        $str = "";
        $str.= "<div class=\"calendar-inner\">";
        $str.= "<h3 id=\"_calcTitle\">Kalkulačka nákladů zapůjčení auta či minibusu:</h3>";
//        $str.= "<h4 id=\"_calcTitle2\">U cest po ČR sleva 10% z ceníkové ceny na půjčení minibusu!!!!</h4>";
        $str.= "</div>";
        $str.= "<div class=\"calendar-inner\">";
//        $str.= "<div class='select-label'>vyberte si vůz, prosím</div>";
        $str.= "<div class=\"calbox1\" id=\"_calcSelect\">";
        $str.= "<select id=\"CarPicker\" onchange=\"Odoprag_DateChange();\" title='vyberte si vůz, prosím'>";
        $str.= "<option value=\"0\">- VYBERTE AUTO -</option>";
        if(($data = $DB->Select("Cars","`ShowInCalc`=1",$data_count,"`SortPos` ASC, `Created` ASC")) !== false && $data_count > 0) {
            for($cc=0; $cc<$data_count; $cc++) {
                $selected = "";
                $str.= "<option value=\"".$data[$cc]->ID."\" $selected>".$data[$cc]->Title."</option>";}}
        $str.= "</select>";
        $str.= "</div>";
        $str.= "</div>";
        
        $str.= "<div class=\"calendar-inner\">";
     
        $str.= "<div class=\"calbox2\" id=\"_calcDate\">";
        $str.= "<div class=\"callabel\" id=\"_calcDateFrom\">Datum od:</div>";
        $str.= "<div class=\"calbtn\" id=\"DatePickerFrom\" onclick=\"Odoprag_EditDate('From');\">3.4.2017</div>";
        $str.= "<div class=\"callabel\" id=\"_calcDateTo\">Datum do:</div>";
        $str.= "<div class=\"calbtn\" id=\"DatePickerTo\" onclick=\"Odoprag_EditDate('To');\">10.4.2017</div>";
        $str.= "</div>";
        
        $str.= "<div class=\"calbox3\" id=\"_calcPrice\">";
        $str.= "<div class=\"callabel caldayscount\" id=\"DatePickerDays\">(3 dny)</div>";
        $str.= "</div>";

        $str.= "</div>";
        
        $str.= "<div class=\"calendar-inner\">";
        
        $str.= "<div class=\"calboxvypocet\"><div class=\"block\"><div class=\"title\">Kauce</div><div class=\"pole\"><div class=\"price\" id=\"CarDeposit\">--</div></div></div></div>";
        $str.= "<div class=\"calboxvypocet\"><div class=\"block\"><div class=\"title\">Půjčovné</div><div class=\"pole\"><div class=\"price\" id=\"CarPrice\">--</div></div></div></div>";
        $str.= "<div class=\"calboxvypocet\"><div   class=\"poptavkabutton\"><button id=\"poptavkabutton\" title=\"Vložit do poptávky\" onClick=\"javascript:Odoprag_Kalkulacka_Poptavka();\">Vložit do poptávky</button></div></div>";
        $str.= "</div>";

        $str.= "<div class=\"calendar-inner\">";

        $str.= "<div class=\"calboxvypocet\"><div class=\"block\"><p>Tento <a href=\"/cenik/\">ceník</a> platí pro následující destinace: ČR, Polsko, Německo, Rakousko, Maďarsko, Slovensko,Chorvatsko, Slovinsko, Itálii.</p>";
        $str.= "Ceny pronájmu vozů, mířících do dalších zemí EU nebo mimo EU jsou stanovené individuálně  na základě konkrétní poptávky s ohledem na nájezd km, charakter destinace, počet dnů a typ vozu.</p>";
        $str.= "</div></div></div></div>";

        return $str;
    }
    
    public function OdopragCz_Calendar_Orig() {
        global $MTPS, $DB;
        $str = "";
        $str.= "<div class=\"calendar-inner\">";
        $str.= "<h1 id=\"_calcTitle\">Kalkulačka nákladů zapůjčení auta či minibusu:</h1>";
        $str.= "</div>";
        $str.= "<div class=\"calendar-inner\">";
        $str.= "<div class=\"calbox1\" id=\"_calcSelect\">";
        $str.= "<select id=\"CarPicker\" onchange=\"Odoprag_DateChange();\">";
        $str.= "<option value=\"0\">- VYBERTE AUTO -</option>";
        if(($data = $DB->Select("Cars","`ShowInCalc`=1",$data_count,"`SortPos` ASC, `Created` ASC")) !== false && $data_count > 0) {
            for($cc=0; $cc<$data_count; $cc++) {
                $str.= "<option value=\"".$data[$cc]->ID."\">".$data[$cc]->Title."</option>";}}
        $str.= "</select>";
        $str.= "</div>";
        $str.= "<div class=\"calbox2\" id=\"_calcDate\">";
        $str.= "<div class=\"callabel\" id=\"_calcDateFrom\">Datum od:</div>";
        $str.= "<div class=\"calbtn\" id=\"DatePickerFrom\" onclick=\"Odoprag_EditDate('From');\">3.4.2017</div>";
        $str.= "<div class=\"callabel\" id=\"_calcDateTo\">Datum do:</div>";
        $str.= "<div class=\"calbtn\" id=\"DatePickerTo\" onclick=\"Odoprag_EditDate('To');\">10.4.2017</div>";
        $str.= "</div>";
        $str.= "<div class=\"calbox3\" id=\"_calcPrice\">";
        $str.= "<div class=\"callabel caldayscount\" id=\"DatePickerDays\">(3 dny)</div>";
        $str.= "<div class=\"calprice\" id=\"CarPrice\">--- Kč</div>";
        $str.= "</div>";
        $str.= "</div>";
        return $str;
    }    
    public function OdopragCz_Pricelist_bySkupina() {
        //ALTER TABLE `odoprag_cars` ADD `CenikSkupina` BOOLEAN NOT NULL DEFAULT FALSE AFTER `ShowInCalc`;
//ALTER TABLE `odoprag_cars` ADD `CenikTitle` TEXT NOT NULL AFTER `CenikSkupina`;         
        global $User, $MTPS, $DB;
        $str = "";
        if(($data = $DB->Select("Cars","`ShowInCalc`=1 AND `CenikSkupina`=1",$data_count,"`SortPos` ASC, `Created` ASC")) !== false && $data_count > 0) {
            for($aa=0; $aa<$data_count; $aa++) {
                $str.= "<h2>".$data[$aa]->CenikTitle.":</h2>";
                $str.= "<div class=\"cenik\">";
                if(($rows = $DB->Select("Pricelist","`CarID` = '".DBText($data[$aa]->ID)."'",$count,"`MaxDays` ASC, `Created` ASC")) !== false && $count >= 0) {
                    if($count > 0) {
                        $maxdays = 3;
                        if($data[$aa]->MinDays > 0) { $maxdays = $data[$aa]->MinDays; }
                        $sales = false;
                        for($bb=0; $bb<$count; $bb++) {
                            if($rows[$bb]->Sale > 0 && $rows[$bb]->Sale != $rows[$bb]->Price) { $sales = true; break; }}
                        $str.= "<div class=\"pricelist\">";
                        $str.= "<div class=\"pricebox\">";
                        $str.= "<p style=\"border-top: 1px solid black;\">Počet dnů:</p>";
                        $str.= "<p>Cena na den:</p>";
                        if($sales) { $str.= "<p style=\"text-align: right; background: red; color: white;\">Cena po slevě:</p>"; }
                        $str.= "</div>";}
                    for($bb=0; $bb<$count; $bb++) {
                        $str.= "<div class=\"pricebox\">";
                        if($bb < $count-1) {
                            $str.= "<p style=\"border-top: 1px solid black;\">".$maxdays." - ".$rows[$bb]->MaxDays." dní</p>";
                            $str.= "<p style=\"text-align: right;\">".Price($rows[$bb]->Price)."</p>";
                            if($sales) { $str.= "<p style=\"background: red; color: white;\">".Price($rows[$bb]->Sale)."</p>"; }
                            $maxdays = $rows[$bb]->MaxDays + 1;}
                        else {
                            $str.= "<p style=\"border-top: 1px solid black; border-right: 1px solid black;\">".$maxdays." - ".$rows[$bb]->MaxDays." dní</p>";
                            $str.= "<p style=\"border-right: 1px solid black; text-align: right;\">".Price($rows[$bb]->Price)."</p>";
                            if($sales) { $str.= "<p style=\"border-right: 1px solid black; text-align: right;\">".Price($rows[$bb]->Sale)."</p>"; }}
                        $str.= "</div>";}
                    if($count > 0) {
                        $str.= "</div>";}
                        }
                $str.= "<p>Kauce: ".Price($data[$aa]->Deposit)."</p>";
//                $str.= "<p >Uvedené ceny v ceníku <u>jsou konečné</u>, nejsme plátci DPH.</p>";

                if($data[$aa]->Attr_1) {
                
 /*                   $str.= "<div class=\"orange\">";
                    $str.= "<h4>U cest po ČR sleva 10% z ceníkové ceny na půjčení minibusu!!!!</h4>";
                    $str.= "</div>";
 */               }
                
                if(CanAdmin()) {
                    $str.= "<a onclick=\"Odoprag_EditPricelist(".$data[$aa]->ID."); return false;\" href=\"\">Upravit ceník ".$data[$aa]->Title."</a>";}
                $str.= "</div>";
            }
        }
                
//        $str.= "<p style=\"color: blue; font-size: 125%; font-weight: bold; margin-bottom: .5em;\">Uvedené ceny v ceníku <u>jsou konečné</u>, nejsme plátci DPH.</p>";
        return $str;
    }
    
    public function OdopragCz_Pricelist() {
        global $User, $MTPS, $DB;
        $str = "";
        if(($data = $DB->Select("Cars","`ShowInCalc`=1",$data_count,"`SortPos` ASC, `Created` ASC")) !== false && $data_count > 0) {
            for($aa=0; $aa<$data_count; $aa++) {
                $str.= "<h2>".$data[$aa]->Title.":</h2>";
                $str.= "<div class=\"cenik\">";
                if(($rows = $DB->Select("Pricelist","`CarID` = '".DBText($data[$aa]->ID)."'",$count,"`MaxDays` ASC, `Created` ASC")) !== false && $count >= 0) {
                    if($count > 0) {
                        $maxdays = 3;
                        if($data[$aa]->MinDays > 0) { $maxdays = $data[$aa]->MinDays; }
                        $sales = false;
                        for($bb=0; $bb<$count; $bb++) {
                            if($rows[$bb]->Sale > 0 && $rows[$bb]->Sale != $rows[$bb]->Price) { $sales = true; break; }}
                        $str.= "<div class=\"pricelist\">";
                        $str.= "<div class=\"pricebox\">";
                        $str.= "<p style=\"border-top: 1px solid black;\">Počet dnů:</p>";
                        $str.= "<p>Cena na den:</p>";
                        if($sales) { $str.= "<p style=\"text-align: right; background: red; color: white;\">Cena po slevě:</p>"; }
                        $str.= "</div>";}
                    for($bb=0; $bb<$count; $bb++) {
                        $str.= "<div class=\"pricebox\">";
                        if($bb < $count-1) {
                            $str.= "<p style=\"border-top: 1px solid black;\">".$maxdays." - ".$rows[$bb]->MaxDays." dní</p>";
                            $str.= "<p style=\"text-align: right;\">".Price($rows[$bb]->Price)."</p>";
                            if($sales) { $str.= "<p style=\"background: red; color: white;\">".Price($rows[$bb]->Sale)."</p>"; }
                            $maxdays = $rows[$bb]->MaxDays + 1;}
                        else {
                            $str.= "<p style=\"border-top: 1px solid black; border-right: 1px solid black;\">".$maxdays." - ".$rows[$bb]->MaxDays." dní</p>";
                            $str.= "<p style=\"border-right: 1px solid black; text-align: right;\">".Price($rows[$bb]->Price)."</p>";
                            if($sales) { $str.= "<p style=\"border-right: 1px solid black; text-align: right;\">".Price($rows[$bb]->Sale)."</p>"; }}
                        $str.= "</div>";}
                    if($count > 0) {
                        $str.= "</div>";}}
                $str.= "<p>Kauce: ".Price($data[$aa]->Deposit)."</p>";
                if(CanAdmin()) {
                    $str.= "<a onclick=\"Odoprag_EditPricelist(".$data[$aa]->ID."); return false;\" href=\"\">Upravit ceník ".$data[$aa]->Title."</a>";}
                $str.= "</div>";
            }
        }
                
        $str.= "<p style=\"color: blue; font-size: 125%; font-weight: bold; margin-bottom: .5em;\">Uvedené ceny v ceníku <u>jsou konečné</u>, nejsme plátci DPH.</p>";
        return $str;
    }

    public function CarFleet_WriteOneCarV22($IDCar) {

        global $User, $MTPS, $DB;
        $str = "";
        if(($data = $DB->Select("Cars","`ID` = '$IDCar' ",$data_count,"`SortPos` ASC, `Created` ASC")) !== false && $data_count > 0) {
            for($aa=0; $aa<$data_count; $aa++) {
                $item = $data[$aa];
            }
        }
        
        $str = "";
        $title = "";
        $title = $item->FullTitle;
        //if(trim($item->SpecialTitle) != "") { $title = $item->SpecialTitle."<br />"; }
        //$title.= $item->FullTitle;

        $text = @str_replace("\r\n","<br />",$item->Text);
        $text = @str_replace("\n\r","<br />",$text);
        $text = @str_replace("\n","<br />",$text);
        
        $str.= "<h2 style=\"padding-top: 1em; color: orange;\">".$title."</h2>";
        $str.= "<table class=\"odotab\">";
        $str.= "<tbody>";
        $str.= "<tr>";
        $str.= "<td style=\"width:40%\">";
        //$str.= "<td style=\"width:233px\">";

        $str.= WEB_Gallery_WriteAlbum_StyleOdoprag($item->AlbumID,false,false);
        $str.= "</td>";
        $str.= "<td style=\"width:auto;\">".$text."</td>";
        $str.= "</tr>";
        $str.= "</tbody>";
        $str.= "</table>";
        return $str;
    }

    public function CarFleetV21() {

        global $User, $MTPS, $DB;
        $str = "";
        if(($data = $DB->Select("Cars","1",$data_count,"`SortPos` ASC, `Created` ASC")) !== false && $data_count > 0) {
            for($aa=0; $aa<$data_count; $aa++) {
                $str.= $this->CarFleet_WriteOneCarV21($data[$aa]);
            }
        }
        return $str;
    }

    public function CarFleet() {

        global $User, $MTPS, $DB;
        $str = "";
        if(($data = $DB->Select("Cars","1",$data_count,"`SortPos` ASC, `Created` ASC")) !== false && $data_count > 0) {
            for($aa=0; $aa<$data_count; $aa++) {
                $str.= $this->CarFleet_WriteOneCarV2($data[$aa]);
            }
        }
        return $str;
    }

    public function CarFleet_WriteOneCarV21($item) {

        global $User, $MTPS, $DB;
        $str = "";
        $title = "";
        $title_category = "";
        if(trim($item->SpecialTitle) != "")  {
            $title_category = $item->SpecialTitle."<br />";
        }

        $title= $item->FullTitle;

        $text = @str_replace("\r\n","<br />",$item->Text);
        $text = @str_replace("\n\r","<br />",$text);
        $text = @str_replace("\n","<br />",$text);

        $str.= "<div id='idcar_$item->ID' class='ContentCar'>";
//        style=\"padding-top: 1em;
        $str.= "<h4  \">".$title_category."</h4>";
        $str.= "<h2 style='color: orange;'>".$title."</h2>";
        $str.= "<div >";
//        $str.= "<div id='data'>";

//        style='width:50%'
//        $str.= "<div style='width:auto; display=block'>";
        $str.= WEB_Gallery_WriteAlbum_StyleOdoprag_21($item->AlbumID,false,false);
//        $str.= "</div>";
        $str.= "<div style='width:auto; display=block'>".$text."</div>";

        $str.= "</div>";
        $str.= "</div>";

        return $str;
    }

    public function CarFleet_WriteOneCarV2($item) {

        global $User, $MTPS, $DB;
        $str = "";
        $title = "";
        $title_category = "";
        if(trim($item->SpecialTitle) != "")
        {
            $title_category = $item->SpecialTitle."<br />";
        }

        $title= $item->FullTitle;

        $text = @str_replace("\r\n","<br />",$item->Text);
        $text = @str_replace("\n\r","<br />",$text);
        $text = @str_replace("\n","<br />",$text);
        $str.= "<h4 style=\"padding-top: 1em; \">".$title_category."</h4>";
        $str.= "<h2 style='color: orange;'>".$title."</h2>";
        $str.= "<table class=\"odotab\">";
        $str.= "<tbody>";
        $str.= "<tr>";
        $str.= "<td style=\"width:233px\">";
        $str.= WEB_Gallery_WriteAlbum_StyleOdoprag($item->AlbumID,false,false);
        $str.= "</td>";
        $str.= "<td style=\"width:auto;\">".$text."</td>";
        $str.= "</tr>";
        $str.= "</tbody>";
        $str.= "</table>";
        return $str;
    }

    public function CarFleet_WriteOneCar($item) {

        global $User, $MTPS, $DB;
        $str = "";
        $title = "";
        if(trim($item->SpecialTitle) != "") { $title = $item->SpecialTitle."<br />"; }
        $title.= $item->FullTitle;
        $text = @str_replace("\r\n","<br />",$item->Text);
        $text = @str_replace("\n\r","<br />",$text);
        $text = @str_replace("\n","<br />",$text);
        $str.= "<h2 style=\"padding-top: 1em; color: orange;\">".$title."</h2>";
        $str.= "<table class=\"odotab\">";
        $str.= "<tbody>";
        $str.= "<tr>";
        $str.= "<td style=\"width:233px\">";
        $str.= WEB_Gallery_WriteAlbum_StyleOdoprag($item->AlbumID,false,false);
        $str.= "</td>";
        $str.= "<td style=\"width:auto;\">".$text."</td>";
        $str.= "</tr>";
        $str.= "</tbody>";
        $str.= "</table>";
        return $str;
    }

    public function CarFleet_WriteOneCarOrig($item) {

        global $User, $MTPS, $DB;
        $str = "";
        $title = "";
        if(trim($item->SpecialTitle) != "") { $title = $item->SpecialTitle."<br />"; }
        $title.= $item->FullTitle;
        $text = @str_replace("\r\n","<br />",$item->Text);
        $text = @str_replace("\n\r","<br />",$text);
        $text = @str_replace("\n","<br />",$text);
        $str.= "<h2 style=\"padding-top: 1em; color: orange;\">".$title."</h2>";
        $str.= "<table class=\"odotab\">";
        $str.= "<tbody>";
        $str.= "<tr>";
        $str.= "<td style=\"width:233px\">";
        $str.= WEB_Gallery_WriteAlbum_StyleOdoprag($item->AlbumID,false,false);
        $str.= "</td>";
        $str.= "<td style=\"width:auto;\">".$text."</td>";
        $str.= "</tr>";
        $str.= "</tbody>";
        $str.= "</table>";
        return $str;
    }

    public function CarFleetSelect() {
        global $User, $MTPS, $DB;
        $str = "";
        if(($data = $DB->Select("Cars","1",$data_count,"`SortPos` ASC, `Created` ASC")) !== false && $data_count > 0) {
            for($aa=0; $aa<$data_count; $aa++) {
                $str.= $this->CarFleet_WriteOneCar($data[$aa]);}}
        return $str;
    }

    public function CarFleetOld() {
        global $User, $MTPS, $DB;
        $str = "";
        if(($data = $DB->Select("Cars","1",$data_count,"`SortPos` ASC, `Created` ASC")) !== false && $data_count > 0) {
            for($aa=0; $aa<$data_count; $aa++) {
                $str.= $this->CarFleet_WriteOneCar($data[$aa]);}}
        return $str;
    }

    public function WriteContactFormBox() {
        global $User, $MTPS, $DB;

        $str = "";
        if($MTPS->confrmTitle != "") {
            $str.= "<h1>".$MTPS->confrmTitle."</h1>";
        }
        if($MTPS->confrmQuestionType) {
            $str.= "<div>";
            $str.= "<h2>Typ dotazu:</h2>";
            $str.= "<p>";
            $str.= "<select id=\"recipient\">";
            $str.= "<option value=\"0\">--- VYBERTE ---</option>";
            $str.= "<option value=\"truhlarstvi@zatrp.cz\">Truhlářství</option>";
            $str.= "<option value=\"zamecnictvi@zatrp.cz\">Zámečnictví</option>";
            $str.= "<option value=\"info@zatrp.cz\">Obecný dotaz</option>";
            $str.= "</select>";
            $str.= "</p>";
            $str.= "</div>";
        }
        $str.= "<div>";
        $str.= "<h2>Vaše jméno:</h2>";
        $str.= "<p><input type=\"text\" maxlength=\"128\" id=\"jmeno\" /></p>";
        $str.= "</div>";
        $str.= "<div>";
        $str.= "<h2>Váš e-mail:</h2>";
        $str.= "<p><input type=\"email\" maxlength=\"128\" id=\"email\" /></p>";
        $str.= "</div>";
        $str.= "<div>";
        $str.= "<h2>Váš telefon:</h2>";
        $str.= "<p><input type=\"phone\" maxlength=\"25\" id=\"telefon\" /></p>";
        $str.= "</div>";
        $str.= "<div>";
        $str.= "<h2>Zpráva:</h2>";
        $str.= "<p><textarea maxlength=\"10000\" id=\"text\"></textarea></p>";
        $str.= "</div>";
        $str.= "<div>";
        $str.= "<h2>&nbsp;</h2>";
        $str.= "<p><input type=\"submit\" value=\"Odeslat\" onclick=\"".$MTPS->confrmOnClick."return false;\" /></p>";
        $str.= "</div>";
        return $str;
    }
    
    public function WriteContactForm() {
        global $MTPS, $DB;
        $str = "";
        $str.= "<div class=\"webContactForm\">";
        if(!IsSet($MTPS->confrmFormOnTop) || (IsSet($MTPS->confrmFormOnTop) && $MTPS->confrmFormOnTop == true)) {
            $str.= $this->WriteContactFormBox();}
        if($MTPS->confrmCompanyTitle != "") {
            $str.= "<h1>".$MTPS->confrmCompanyTitle."</h1>";}
        if(IsSet($MTPS->confrmCompanyText) && $MTPS->confrmCompanyText != "") {
            $str.= "<div class=\"webContactFormCompanyText\">".$MTPS->confrmCompanyText."</div>";}
        if($MTPS->confrmPersonInCharge != "") {
            $str.= "<div>";
            $str.= "<h2>Odpovědná osoba:</h2>";
            $str.= $MTPS->confrmPersonInCharge;
            $str.= "</div>";}
        if($MTPS->confrmSocials) {
            $str.= "<div>";
            $str.= "<h2>Sociální sítě:</h2>";
            if($MTPS->confrmSocialsFacebook != "") {
                $str.= "<p><a href=\"".$MTPS->confrmSocialsFacebook."\" target=\"_blank\">Facebook</a></p>";}
            $str.= "</div>";}
        if($MTPS->confrmOpeningHours != "") {
            $str.= "<div>";
            $str.= "<h2>Otevírací doba:</h2>";
            $str.= $MTPS->confrmOpeningHours;
            $str.= "</div>";}
        if($MTPS->confrmPhone != "") {
            $str.= "<div>";
            $str.= "<h2>Telefon:</h2>";
            $str.= "<p>".$MTPS->confrmPhone."</p>";
            $str.= "</div>";}
        if($MTPS->confrmCellPhone != "") {
            $str.= "<div>";
            $str.= "<h2>Mobil:</h2>";
            $str.= "<p>".$MTPS->confrmCellPhone."</p>";
            $str.= "</div>";}
        if($MTPS->confrmEmail != "") {
            $str.= "<div>";
            $str.= "<h2>E-mail:</h2>";
            $str.= "<p><a href=\"mailto:".$MTPS->confrmEmail."\">".$MTPS->confrmEmail."</a></p>";
            $str.= "</div>";
            if($MTPS->confrmEmail2 != "") {
                $str.= "<div>";
                $str.= "<h2>&nbsp;</h2>";
                $str.= "<p><a href=\"mailto:".$MTPS->confrmEmail2."\">".$MTPS->confrmEmail2."</a></p>";
                $str.= "</div>";}}
        if($MTPS->confrmWorkshopAddress != "") {
            $str.= "<div>";
            $str.= "<h2>Provozovna:</h2>";
            $str.= $MTPS->confrmWorkshopAddress;
            $str.= "</div>";}
        if(IsSet($MTPS->confrmFormOnBottom) && $MTPS->confrmFormOnBottom == true) {
            $str.= $this->WriteContactFormBox();}
        if($MTPS->confrmICO != "") {
            $str.= "<div>";
            $str.= "<h2>IČ:</h2>";
            $str.= "<p>".$MTPS->confrmICO."</p>";
            $str.= "</div>";}
        if($MTPS->confrmDIC != "") {
            $str.= "<div>";
            $str.= "<h2>DIČ:</h2>";
            $str.= "<p>".$MTPS->confrmDIC."</p>";
            $str.= "</div>";}
        if($MTPS->confrmISDS != "") {
            $str.= "<div>";
            $str.= "<h2>Datová schránka:</h2>";
            $str.= "<p>".$MTPS->confrmISDS."</p>";
            $str.= "</div>";}
        if($MTPS->confrmInvoiceAddress != "") {
            $str.= "<div>";
            $str.= "<h2>Fakturační adresa:</h2>";
            $str.= $MTPS->confrmInvoiceAddress;
            $str.= "</div>";}
        if($MTPS->confrmMapyCz != "") {
            $str.= "<div>";
            $str.= "<h2><a href=\"".$MTPS->confrmMapyCz."\" target=\"_blank\">Mapy.cz</a>:</h2>";
            $str.= "<p>".$MTPS->confrmMapyCzIframe."</p>";
            $str.= "</div>";}
        if($MTPS->confrmPicture != "") {
            $str.= "<div>";
            $str.= "<img src=\"".$MTPS->confrmPicture."\" alt=\"".$MTPS->confrmPictureHint."\" />";
            $str.= "</div>";}
        $str.= "</div>";
        return $str;
    }
    public function writeGalleryAlbumsOnHomepage() {
        global $MTPS;
        $str = "";
        if(CanAdmin()) {
            $str.= "<p>";
            $str.= "Administrace: ";
            $str.= "<a href=\"\" onclick=\"galleryEditAlbumOnHomepage(0);return false;\">".Lng('AddAlbumToHomepage')."</a>";
            $str.= "</p>";}
        $str.= galleryWriteAlbumAsPresentation(2);
        $str.= galleryWriteAlbumAsPresentation(3);
        $str.= galleryWriteAlbumAsPresentation(4);
        return $str;}
    public function mtpsCSS() {
        global $MTPS;
        $str = "";
        for($aa=0; $aa<count($MTPS->kwiModules); $aa++) {
            $___mtps3file = $GLOBALS['fileWEB']."templates/".$MTPS->DefaultLayout."/modules/".$MTPS->kwiModules[$aa]."/".$MTPS->kwiModules[$aa].".css";
            if(@file_exists($___mtps3file)) {
                $___mtps3file = $GLOBALS['urlWEB_NO_LNG']."templates/".$MTPS->DefaultLayout."/modules/".$MTPS->kwiModules[$aa]."/".$MTPS->kwiModules[$aa].".css";
                $str.= "<link rel=\"stylesheet\" type=\"text/css\" href=\"".$___mtps3file."\" />";}}
        return $str;}
    public function mtpsJS() {
        global $MTPS;
        $str = "";
        for($aa=0; $aa<count($MTPS->kwiModules); $aa++) {
            $___mtps3file = $GLOBALS['fileWEB']."templates/".$MTPS->DefaultLayout."/modules/".$MTPS->kwiModules[$aa]."/".$MTPS->kwiModules[$aa].".js";
            if(@file_exists($___mtps3file)) {
                $___mtps3file = $GLOBALS['urlWEB_NO_LNG']."templates/".$MTPS->DefaultLayout."/modules/".$MTPS->kwiModules[$aa]."/".$MTPS->kwiModules[$aa].".js";
                $str.= "<script src=\"".$___mtps3file."\"></script>";}}
        return $str;}
    public function indexCssPrefix() {
        global $MTPS;
        if($MTPS->IsIndexPage) { return "index-"; }
        return "";}
    };

    require("index-Mailer.php");
    require("index-3.php");

    require("index-2.php");

    ?>
